osirion

Well-Known Member
Jan 16, 2007
54
4
158
Hi Everyone,
I have my 'rotatelogs_size_threshhold_in_megabytes' under tweak settings set to 500MB.
However, I have various customers with error_log files at 1GB,2GB and even 6GB.

1) How do I enforce the error_log file limit at 500MB for all accounts/server wide?

2) Will running the below help me clear the contents of all error_log files bigger than 499MB:
Code:
for i in $(find /home -type f -iname error_log -size +499M);do : > $i;done
Thanks in advance!
 
Last edited:

Vs Nu

Well-Known Member
Jul 17, 2015
110
7
68
India
cPanel Access Level
Root Administrator
You can create an cron script to remove the error_log file in your server (All cPanels)

If you assign 500M For each account,Just imagine if 20 accounts got 500M Fully on error_log so it will eat some amount of Disk

You can use the below command to remove the error_log files certain days once.

Code:
rm -rfv /home/*/error_log
rm -rfv /home/*/public_html/error_log
 

osirion

Well-Known Member
Jan 16, 2007
54
4
158
Thanks for the response vs Nu - but I think something may be getting lost in translation here.
I dont want to remove error_log files daily as they hold valuable information. I just want them to be limited to 500MB and want it to trash the old entries in place of the new entries (so that the error_log file never exceeds 500MB).

After I fix cPanel to work as per the above (as its supposed to?) - then only will I run my command ([2] above) to clear any files that are above the 500MB limit (I was just making sure the command was correct so that I dont accidentally cause unwanted destruction).
 

GOT

Get Proactive!
PartnerNOC
Apr 8, 2003
1,743
306
363
Chesapeake, VA
cPanel Access Level
DataCenter Provider
cPanel does not rotate user error_logs. It doesn't even try. I cannot offhand think of a way to incorporate logrotate into that mix either.

Just spitballing here, but you might be able to use something similar to

find /home -name error_log -exec truncate --size=500M {} \;

I did read that that might increase the size of the file to 500M if its smaller, but did not test, you'll want to play with it.
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,295
1,257
313
Houston
You could use logrotate to do this but it wouldn't do it based off of size it would only do it based off of a schedule (daily, weekly, etc.)

You can use wildcards as follows for it as well if all of the error_logs are in the same location in each account so /home/*/path/to/log

This can be configured in the section labeled:
# system-specific logs may be configured here

at /etc/logrotate.conf