hussam Posted April 1, 2014 Posted April 1, 2014 Since they count towards disk space, any way to disable their generation?I can log onto my cpanel every half a day and delete them but they tend to hide in random folders on my wordpress installation.
Ice IT Support Posted April 3, 2014 Posted April 3, 2014 Error log files aren't that large, but can be a nuisance. Below is a script that will delete all error_log files from your account. Copy the code below into a PHP file: <?php error_reporting(0); ## read through directories ## $it = new RecursiveDirectoryIterator("$_SERVER[DOCUMENT_ROOT]"); foreach(new RecursiveIteratorIterator($it) as $file) { ## remove document root so it doesn't get searched ## $file = preg_replace("@$_SERVER[DOCUMENT_ROOT]@", "", $file); ## get directory name and file extension ## $extract = pathinfo($file); $dname = ($extract['dirname']); $ext = ($extract['basename']); ## find files ## if ( preg_match("/error\_log/", $ext, $match) ) { $files[] = "$dname/$ext"; } } ## loop through files ## asort($files); $files = preg_replace("@//@", "/", $files); foreach($files as $value) { $path = "$_SERVER[DOCUMENT_ROOT]$value"; unlink("$path"); echo "Removed: $path<br>"; } ?> Adapted from Byron's core dump sweeper (http://bybyron.net/helio/cordump_sweeper.txt) 1
Byron Posted April 3, 2014 Posted April 3, 2014 You could also add that file to a php include on one of your pages so that when somebody visited your page, it would run the script. If you want to do that you'll need to edit the file so that there's no output like this: { $path = "$_SERVER[DOCUMENT_ROOT]$value"; unlink("$path"); # echo "Removed: $path<br>"; } exit; ?> Then add this at the bottom of your page: <?php include("sweeper.php"); ?> 1
hussam Posted April 3, 2014 Author Posted April 3, 2014 Alright, thank you. I added a sweeper.php file and ran it. it cleaned two error_log files. thank you very much
yashrs Posted April 12, 2014 Posted April 12, 2014 Can't we simply add error_reporting(0); to php so that it doesn't generate error_log files ? 1
Ice IT Support Posted April 13, 2014 Posted April 13, 2014 That would would work for the most part. Syntax errors would still come through I think.
Byron Posted April 14, 2014 Posted April 14, 2014 Plus he'd have to add that to EVERY php page he had on his site.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now