Delete error_log Files on cPanel Servers

Ever wanted to easily and quickly dispose of error_log and/or <domain>.php.error.log files on your cPanel server? Fortunately, there's a way to do just that!

find /home/* -path /home/virtfs -prune -o -type f -name error_log -exec /bin/rm -fv {} \;
find /home/* -path /home/virtfs -prune -o -type f -name *php.error.log -exec /bin/rm -fv {} \;

The above commands will search all of the cPanel accounts in your home directories for files named error_log and/or <domain>.php.error.log and remove any that it finds. It will also exclude /home/virtfs/, as files in this directory are read-only. It will create a list of the files that it removed, like so:

root@server [~]# find /home/* -path /home/virtfs -prune -o -type f -name error_log -exec /bin/rm -fv {} \;
removed ‘/home/testuser/public_html/error_log’
root@server [~]#

  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

You may be familiar with ClamAV and Maldet (aka Linux Malware Detect). They're widely known as two excellent choices for identifying malware. What you may not realize, however, is that they can be...

Read More ...

On cPanel servers, you may come across the process /usr/local/cpanel/bin/mysqluserstore/usr/local/cpanel/bin/mysqluserstore creates and updates the /var/cpanel/databases/users.db and...

Read More ...

If your server is running cPanel/WHM, simply execute the below commands via SSH (as root):wget http://www.litespeedtech.com/packages/cpanel/lsws_whm_plugin_install.shsh...

Read More ...

If you're like us, you'll want your server's timezone to match your local time to make log management easier. Fortunately, this is easy to do! This guide works perfectly on servers running CentOS...

Read More ...

This nifty command allows you to built up a list of the largest files and directories:FS='/';clear;date;df -h $FS; echo "Largest Directories:"; du -hcx –max-depth=2 $FS 2>/dev/null | grep [0-9]G...

Read More ...