How To Clean your cPanel Logs Files in One Go

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?

 Print this Article

Also Read

How to Refresh your cPanel License

If you have purchased your linux VPS along with a cPanel license. Your license won't be active...

How To Update cPanel From SSH or GUI

In order to update the cPanel software on a Linux VPS, there is 2 ways to do it. Upgrading the...

How To Backup / Restore / Export your CSF Firewall Configuration

Whenever you want to deploy a new Linux VPS / Dedicated server, you generally have to set and...

How to Install the CSF / LFD Firewall on your VPS / Dedicated Server

Throughout this guide, you'll learn how to install your own Firewall on your linux VPS /...

How to activate TUN/TAP on your Linux VPS

Throughout this tutorial, we will show you how to activate the TUN / TAP feature on your linux...