View Full Version : Clearing Error Logs
Techgy
09-22-2007, 01:35 PM
Is it possible to clear the Error Logs (cpanel) from outdated errors?
linFox
09-23-2007, 08:52 AM
If you mean clear the PHP errors (that is, delete all error_log files), then you can get a script to do it fairly easily.
This will do it (this could probably be done with one line of code on the console, but, oh well. This is pure PHP):
<?php
$rootdir = $_SERVER['DOCUMENT_ROOT'];
function del_error_log($dir) {
if ($fh = opendir($dir)) {
while (false !== ($file = readdir($fh))) {
if ($file != "." && $file != "..") {
if (is_dir($dir."/".$file)) {
del_error_log($dir."/".$file);
}
elseif ($file == "error_log") {
unlink($dir."/".$file);
echo "Deleted: ".$dir."/".$file."<br />\n";
}
}
}
closedir($fh);
}
}
del_error_log($rootdir);
?>
Techgy
09-23-2007, 03:53 PM
Thanks for the response. I'll give it a shot.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.