SOLVED Disk space issues, and questions

Operating System & Version
CENTOS 7.9 virtuozzo
cPanel & WHM Version
v98.0.8

jasoncollege24

Active Member
Mar 25, 2012
30
3
58
Portsmouth, Virginia, United States
cPanel Access Level
Root Administrator
server has a 30GB drive. I have root access to the server. (CentOS7.9 virtuozzo, cPanel v98.0.8)

As it stands right now, total disk usage is 9.21GB, 2.4 of that is used by /home. Before this, it was nearly 16GB.

I deleted journal logs older than today, which freed up the additional space.

Current high usages are:
/backup 633MB (expected)
/home 2.4GB (expected)
/opt 519MB (guessing this is normal)
/usr 4.3GB
/usr/cpanel 2.4GB (largest in /usr)
/var/log 361MB (was 2.4GB)

1. How much disk space should be used, on average, for /usr (or /usr/cpanel if the rest seems normal)?
2. Is there an automatic method of clearing unmanaged log files, or limiting the amount of space they take up? Seems pretty tedious to login via SSH, and issue several manual commands every couple of months, to do something that could be done automatically. Also, I'm not really even sure which log files are safe to delete, or clear.
3. Is there an automatic way of clearing logs retained by WHM in /usr/local/cpanel/logs/archive/ ? This is easier, since these logs can take several months to rotate, but more often than not, problems get resolved, before the logs are even rotated, and retained logs are never looked at.

If the answer to question 1 is that these sizes seem normal, then let's concentrate on the logs. :)
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,494
1,009
313
cPanel Access Level
Root Administrator
Hey there! Here's what I see in my own /usr/ partition:

Code:
[[email protected] usr]# du -h --max-depth 1
12K    ./src
4.0K    ./games
545M    ./sbin
69M    ./libexec
1018M    ./lib
39M    ./include
435M    ./bin
2.6G    ./local
4.0K    ./etc
572M    ./lib64
584M    ./share
5.8G    .
/usr/local/cpanel is nearly the entire 2.6G represented in /usr/local/ from the above output.

cPanel does have log rotation tools as outlined in our documentation here, so checking those out would definitely be worthwhile and will help out with questions 2 and 3: Log Rotation | cPanel & WHM Documentation

Let me know if you need more than that!
 

jasoncollege24

Active Member
Mar 25, 2012
30
3
58
Portsmouth, Virginia, United States
cPanel Access Level
Root Administrator
based on your reply, it looks like /usr is the correct size. However, your reply doesn't provide a solution to questions 2, and 3.

I've changed the size of rotated logs to 100MB in the WHM interface, which takes care of log rotation size for managed log files, but doesn't handle removal of these retained logs, which have never been needed. (the question was looking for a way to automatically remove these)

I removed more than 5GB worth of unmanaged logs from /var/log/journal today, which is ridiculous, and *must* be done every 1-2 months, if I want to keep my free disk space. (the question was looking for a way to automatically remove these)

Edit: for question 2, I added a script in /etc/cron.monthly which runs the command "rm -rf /var/log/journal/*" I'll probably add something similar for managed logs, once they start rotating. Thanks for the help! :)
 
Last edited:

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,494
1,009
313
cPanel Access Level
Root Administrator
A default server doesn't have the /usr/local/cpanel/logs/archive directory, so can't say for sure what exactly would have created and placed files there.

As far as /var/log/journal, that isn't something that is controlled by cPanel either, but is handled directly by the operating system. This can usually be controlled by options in the /etc/systemd/journald.conf file, but a cron deleting those entries is also safe as long as you don't remove the directory itself.
 

jasoncollege24

Active Member
Mar 25, 2012
30
3
58
Portsmouth, Virginia, United States
cPanel Access Level
Root Administrator
the directory /usr/local/cpanel/logs/archive is not created on install. It is used by cPanel to rotate (archive) managed logs, and is only created the first time the logs are rotated. WHM tells you about this archive destination, if you login, and go to Home > Service Configuration > cPanel Log Rotation Configuration. This was further proved, when I lowered the rotation threshold from the default of 300MB, to 100MB, causing multiple managed logs to be rotated, because many ranged from 100-150MB in size.

I chose the cron method, for the journal logs, because it's a bit easier for someone still learning linux to add a simple script, than it would be to look up various logs, their settings, and how to change them. My preferred Linux OS is ubuntu, which is not supported by cPanel. and CentOS is definitely a bit different than ubuntu, so it's still a learning curve.

The script leaves the /var/log/journal/ directory in place, and deletes everything in it. Once I figure out the best timing for doing the same to managed logs, I will likely add another script to do something similar.

How do I mark this issue as being resolved?