I looked into this again and see I’m getting tons of rotated error logs.
[root@wcloud:/usr/local/lsws/logs]# ls -lah
total 5.2G
drwxr-x— 2 root nobody 68K Oct 8 14:05 .
drwxr-xr-x 26 root root 4.0K Sep 30 11:28 …
-rw-r–r-- 1 nobody nobody 792 Sep 30 13:06 access_log
-rw-r–r-- 1 nobody nobody 15K Sep 30 12:30 access.log
-rw-r–r-- 1 nobody nobody 1.4M Oct 8 12:08 auditmodsec.log
-rw-r–r-- 1 nobody nobody 6.2M Oct 8 14:31 error.log
-rw-r–r-- 1 nobody nobody 3.2M Sep 30 12:47 error.log.2019_09_30
-rw-r–r-- 1 nobody nobody 2.3M Sep 30 13:04 error.log.2019_09_30.01
-rw-r–r-- 1 nobody nobody 1.2M Sep 30 13:09 error.log.2019_09_30.02
-rw-r–r-- 1 nobody nobody 3.5M Sep 30 13:18 error.log.2019_09_30.03
-rw-r–r-- 1 nobody nobody 12M Sep 30 13:34 error.log.2019_09_30.04
-rw-r–r-- 1 nobody nobody 11M Sep 30 14:17 error.log.2019_09_30.05
-rw-r–r-- 1 nobody nobody 11M Sep 30 14:43 error.log.2019_09_30.06
Checking most of these error logs are under 7 days old.
[root@wcloud:/usr/local/lsws/logs]# find /usr/local/lsws/logs/error.log.* -mtime +7 -type f | wc -l
6
The majority of these are within a day old which is outrageous.
[root@wcloud:/usr/local/lsws/logs]# find /usr/local/lsws/logs/error.log.* -mtime +1 -type f | wc -l
376
[root@wcloud:/usr/local/lsws/logs]#
After cleared:
[root@wcloud:/usr/local/lsws/logs]# du -h /usr/local/lsws/logs/
1.5G /usr/local/lsws/logs/
[root@wcloud:/usr/local/lsws/logs]#
There is an even easier way to fix this if you do not want to change the keepdays or logging level via the Litespeed web admin panel.
Use the below in a cronjob adjusted for how long you want the oldest files to be.
0 1 * * * find /usr/local/lsws/logs/error.log.* -mtime +1 -type f delete >/dev/null 2>&1
The -mtime is the time of the file age. Anything older than 1 day will be selected for deletion in this example.
find /usr/local/lsws/logs/error.log.* -mtime +1 -type f delete
I highly advise first testing it without the delete directive to ensure it’s finding the desired files which are taking up space.
find /usr/local/lsws/logs/error.log.* -mtime +1 -type f
As it logs “error.log.*” this is why my example is this way.
Once you tested it then you can test with the delete option and if that works to your liking simply set it up as a cronjob via the root user.
find /usr/local/lsws/logs/error.log.* -mtime +1 -type f delete
Once decided on the command create the job as root user.
crontab -e
0 1 * * * find /usr/local/lsws/logs/error.log.* -mtime +1 -type f delete >/dev/null 2>&1
Enjoy no more worries about disk space.
This is going to be way easier than trying to set up logrotate on top of the rotation litespeed/openlitespeed already has going.