tbrehm
2010-06-29 3e0034c1dc3eb944d4e275b62c314cf01dbeda96
Implemented: FS#1109 - Rotate website error logs and ispconfig log
2 files modified
19 ■■■■■ changed files
server/conf/vhost.conf.master 1 ●●●● patch | view | raw | blame | history
server/cron_daily.php 18 ●●●●● patch | view | raw | blame | history
server/conf/vhost.conf.master
@@ -23,6 +23,7 @@
    ServerAdmin webmaster@<tmpl_var name='domain'>
    ErrorLog /var/log/ispconfig/httpd/<tmpl_var name='domain'>/error.log
<tmpl_if name='errordocs'>
    ErrorDocument 400 /error/400.html
server/cron_daily.php
@@ -207,6 +207,13 @@
        exec("gzip -c $logfile > $logfile.gz");
        unlink($logfile);
    }
    // rotate and compress the error.log when it exceeds a size of 10 MB
    $logfile = escapeshellcmd($rec["document_root"].'/log/error.log');
    if(is_file($logfile) && filesize($logfile) > 10000000) {
        exec("gzip -c $logfile > $logfile.1.gz");
        exec("cat /dev/null > $logfile");
    }
    // delete logfiles after 30 days
    $month_ago = date("Ymd",time() - 86400 * 30);
@@ -217,6 +224,17 @@
}
#######################################################################################################
// Rotate the ispconfig.log file
#######################################################################################################
// rotate the ispconfig.log when it exceeds a size of 10 MB
$logfile = '/var/log/ispconfig/ispconfig.log');
if(is_file($logfile) && filesize($logfile) > 10000000) {
    exec("gzip -c $logfile > $logfile.1.gz");
    exec("cat /dev/null > $logfile");
}
#######################################################################################################
// Cleanup website tmp directories
#######################################################################################################