Alongar

Member
Oct 5, 2019
21
2
3
America
cPanel Access Level
Website Owner
Hello,

I have a question. When trying to empty the cPanel error logs via command:
Code:
echo > /usr/local/cpanel/logs/error_log
It returns an error message "bash: /usr/local/cpanel/logs/error_log: Operation not permitted." Is this a directory/file permission(s) issue? I am using terminal access as well within WHM. Any help would be appreciated.
 

quietFinn

Well-Known Member
Feb 4, 2006
1,386
174
193
Finland
cPanel Access Level
Root Administrator
You must be logged in as root if you want to delete or clear that log (or any cPanel logs).
 

quietFinn

Well-Known Member
Feb 4, 2006
1,386
174
193
Finland
cPanel Access Level
Root Administrator
It still does not work, even logged in as root.
if you zero the log file you must restart the service, i.e. (if it's cPanel's log file)
service cpanel restart
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,295
1,273
313
Houston
This won't work even as the root user because the cPanel error logs are set to append only:

Code:
[[email protected] logs]# lsattr /usr/local/cpanel/logs/error_log
-----a-------e-- /usr/local/cpanel/logs/error_log
This is not the best way to clear cPanel log files, I would suggest you do the following to maintain the cPanel log files:

1. Go to WHM>>Service Configuration>>cPanel Log Rotation Configuration -> Select all logs you'd like to be rotated (in most cases this should be every log file listed)
2. Go to WHM>>Service Configuration>>Tweak Settings -> Log rotation size threshold -> Select the size which you'd like for the cPanel related log files to be rotated

This will ensure that every time cPanellogd runs it will check the size of these log files to ensure they do not exceed the threshold, if/when they do they'll be rotated out to /usr/local/cpanel/logs/archive/ and compressed