Knowledgebase

How To Clean your cPanel Logs Files in One Go Print

  • 84

This tutorial is meant to provide a shortcut to clean your log files in a cPanel Dedicated Server or a cPanel Linux VPS.

**Disclaimer** Prior to erasing permanently your log files, you need to insure that there isn't critical problems parsed in the logs that would need to be issued promptly.

We are going to create a shell script that will through SSH clean the logs files in launching the script.

1) Login to your VPS in SSH with Putty or any SSH client

2) Create a folder where you'll place your customs script (it allows you to stay organized), typing the following command:

mkdir /customscripts

3) Create and edit a file with the following command

vi /customscripts/logs

** i to start editing
** esc to quit editing

4) Copy / Paste the following :

echo > /usr/local/apache/logs/error_log
echo > /usr/local/apache/logs/access_log
echo > /usr/local/apache/logs/access_log
echo > /usr/local/apache/logs/error_log
echo > /usr/local/cpanel/logs/access_log
echo > /usr/local/cpanel/logs/error_log
echo > /var/log/exim_mainlog
echo > /var/log/exim_rejectlog
echo > /var/log/maillog
echo > /var/log/messages
echo > /var/log/messages.1
echo > /var/log/maillog.1

5) Push the esc button and type :wq! with ":" included to save the file


6) We need to give the authorization to the script to perform the task with the following command

chmod 755 logs

7) Let's run the script and clean your logs files!

./logs

Was this answer helpful?

« Back

Start typing and press Enter to search