Remove error_log files on a cPanel server

Remove-error_log-files-on-a-cPanel-server

We will show you how to free up disk space by deleting/removing error_log files. You can remove the error_log files either by a single command or using a CRON JOB for automatic removal.

Note: Take the backups before you start. If you have limited server resources, then it would take a long time to run these commands.

Locate error_log Files on cPanel Servers:

First, let’s locate the error_log file using the command:

 find /home -type f-iname error_log -exec du -sh {} \;

-type: Specify the type to find.

-iname: Specify the name to find.

-exec: Execute the “du -sch” and lists the output with file size.

If you want to list the error_log files bigger than 50MB? You can use the below command, but remember that based on the file size you choose the run time of the commands would increase accordingly.

find /home/*/public_html -type f -name error_log -size+50000k -exec du -sh {} \;

Remove all error_log files:

The command “find” has a “delete” option to remove all the error_log file from the directory. Check the below command to remove error_log files:

 find /home -type f-iname error_log –delete

-delete: This switch used to remove all the outputs from the find command.

Remove error_log files using CRONJOB

The command “CRONJOB” is used to remove the error_log files periodically. Follow the below code to create cron.

/bin/find /home -type f -iname error_log –delete
 For example: * 21* */bin/find/home –type f –iname error_log –delete

This command line will delete all the error_log files periodically every day at 9 PM server time.

If you find any issues in a particular file, you can change the file location accordingly.

Hope it helps. If you need any assistance Contact Us.

You can also check: 7 Tips to free disk space on cPanel server

For more tips and updates follow us on Facebook, Twitter, LinkedIn

Subscribe to get free blog content to your Inbox
Loading

Written by actsupp-r0cks