cPanel Log Locations

cPanel emtpy trash for all users

 

cPanel

All cPanel logs are located in the folder:

/usr/local/cpanel/logs

The access_log contains all traffic to WHM, cPanel, and Webmail:

/usr/local/cpanel/logs/access_log

The error_log contains all errors when accessing a cPanel related site:

/usr/local/cpanel/logs/error_log

 

Apache

On cPanel servers each site has its own traffic log, but Apache's main access log can be viewed here:

/usr/local/apache/logs/access_log

To view each cPanel accounts individual access-logs:

/usr/local/apache/domlogs

Apache errors are logged to the error_log file:

/usr/local/apache/logs/error_log

 

Exim

The exim main log contains all transaction information:

/var/log/exim_mainlog

The reject log contains all connections that were rejected:

/var/log/exim_rejectlog

 

FTP

Regardless of the FTP server chosen in cPanel, it does not have it's own log and instead logs to:

/var/log/messages

 

SSH

On most servers the SSH service will log to the secure and system messages log files:

/var/log/secure
/var/log/messages

 

 

 

Manually Export MySQL Database

Find largest folder in ssh

How do I manually export or "dump" a MySQL database from command line or SSH?

You can dump a MySQL database to the current folder from an SSH session using the following command:

mysqldump –no-create-db=true -uUSERNAME -pPASSWORD DATABASE > filename.sql

So if your database name is "USER_MYDATABASE" and your database username is "USER_USER1" and the password is "PASSWORD1" and you would like to save the dump as "mydump.sql", you would use the following:

mysqldump –no-create-db=true -uUSER_USER1 -pPASSWORD1 USER_MYDATABASE > mydump.sql

 

 

 

Search For Specific Text In File

Find largest folder in ssh

How can I find a specific text string in a file or multiple files from an SSH session?

You can use the grep command to easily find text within files.

From an SSH session, run the following command:

grep -H -r "<Text-To-Find>" <search-location>

Where <Text-To-Find> would be replaced with the text you want to search for and <search-location> is where the files are located that you want to search within.

For example, if you wanted the find all files containing the string "base64_decode" in the home folder, you would use:

grep -H -r "base64_decode" /home

 

 

 

Bulk Edit DNS Zone On cPanel

cPanel emtpy trash for all users

How do I bulk edit a DNS zone on cPanel?

Changed nameserver name and need to update all the DNS zones on your cPanel server?

Using the replace command from an SSH session will make it simple.

Just use the following command:

replace "<old-nameserver>" "<new-nameserver>" — /var/named/*.db

Where <old-nameserver> is the hostname of the old nameserver and <new-nameserver> is the new namserver hostname you want to replace it with.

You should then restart the DNS service:

service named restart

 

 

 

Explanation Of Cron Times

Find largest folder in ssh

New to setting up cron jobs and need to know what each digit means?

The following is an example of each digit and its function:

*    *    *    *    *        command to be executed
|     |     |    |    |
|     |     |    |    +—– day of week (0 – 6) (Sunday=0)
|     |     |    +——- month (1 – 12)
|     |     +——— day of month (1 – 31)
|     +———– hour (0 – 23)
+————- min (0 – 59)

 

 

Find And Remove Old cPanel Backups

cPanel emtpy trash for all users

How do I find and remove old cPanel backups?

Use the following command from an SSH session to find all backups that are older than 60 days and delete them:

find /backup/weekly/incremental/accounts -maxdepth 1 -type d -ctime +60 -exec rm -rf {} \;

In the above example we find all weekly incremental backups that are older than 60 days and delete them.

You can change the folder location to suit your needs.

Please note: Be very careful to make sure you get the folder path right because it does not prompt you for approval and goes simply by age, so it does not know the difference between a backup folder and an unrelated folder.