Make a single access log on cPanel servers

Sometimes it might be useful to make a single access log on cPanel servers, if you need to either investigate a problem, or you just need to get some general information from all sites hosted on a specific server, it could be the number of requests to wp-cron.php etc.

In cPanel all log files is stored within /usr/local/apache/domlogs/, and is seperated by domain, which is useful sometimes, but it would also be useful to have a single access log from time to time, so to do this, we can run a very simple command:

cd /usr/local/apache/; find domlogs/ -type f ! -name *.gz ! -name *-ftp_log ! -name *-bytes_log ! -name *.offset* ! -name *-ssl* -exec cat {} >> access_log \;

The code above is pretty simple, first it go into the /usr/local/apache/ folder, then using the find command for the domlogs folder, looking for all files using the -type f, and then exclude all files ending on .gz, -ftp_log, -bytes_log, .offset and -ssl*. We cat all the files it finds, and redirect the output to access_log.

The reason why the SSL logs is excluded is that, all domains running SSL will have this file, but they will log to 2 files at same time, so in fact we would just get the data from 1 site twice if we didn’t exclude it.

You now have the access_log file located at /usr/local/apache/access_log, so you can get whatever data is needed.