Mass Removal of error_log Files

12 Oct

It’s always a good idea to back something up before you begin working on an improvement to it or upgrading it to a new version. For example, before I upgrade my WordPress installs I always back up their files and databases.

This seems simple enough but every time I back up any of my PHP projects (WordPress or any other) I seem to run into the same problem: error_log files.

error_log files are the product of Apache’s error logging functionality. Whenever you go to a site running an Apache webserver and get a PHP error the error is put in a file called error_log that is stored in the directory in which the file that throws the error resides. For example, if you get a PHP error when trying to access the error will be logged in an error_log file in the root of the site. However if you get an error when trying to visit the will be logged to error_log in the /test subdirectory.

The problem is that over time these files can grow very large and be spread through many directories all over your website. So when you try to back up numerous directories you can end up with a larger than necessary backup file filled with many error_log files (some of which can grow quite large themselves). And since these files do not serve any other need but to log errors it seems useless to have them in your backup.

The good news is that error_log files can be removed at any time with no repercussions to the functionality of other files within their directories. But the removal of these files can prove to be a difficult since they can be in any directory. Who wants to manually look in every directory of a WordPress install to find and delete all the instances of error_log files?

Luckily I chanced upon a solution by Lester “GaMerZ” Chan. GaMerZ wrote a PHP script called “GaMerZ error_log Cleaner”. When it’s page is accessed “GaMerZ error_log Cleaner” crawls your website for error_log files and removes them all automatically. “GaMerZ error_log Cleaner” can be downloaded here.

As an added tip I’d suggest changing the name of the error_log.php file for security purposes lest it become an attack vector. If you do this then be sure to change the $this_file variable at the top of the script to match the new filename.

URL download:

Leave a comment

Posted by on October 12, 2011 in Computer, Wordpress


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: