Skip to content
Snippets Groups Projects
Commit fe8ea3f1 authored by Florian Schaal's avatar Florian Schaal
Browse files

daily rotate for ispconfig-logs (ispconfig.log, cron.log, auth.log) up to 10 days

parent ed1073fe
No related branches found
No related tags found
No related merge requests found
...@@ -175,25 +175,26 @@ class cronjob_logfiles extends cronjob { ...@@ -175,25 +175,26 @@ class cronjob_logfiles extends cronjob {
// Rotate the ispconfig.log file // Rotate the ispconfig.log file
//###################################################################################################### //######################################################################################################
// rotate the ispconfig.log when it exceeds a size of 10 MB $num = 10;
$logfile = $conf['ispconfig_log_dir'].'/ispconfig.log';
if(is_file($logfile) && filesize($logfile) > 10000000) {
exec("gzip -c $logfile > $logfile.1.gz");
exec("cat /dev/null > $logfile");
}
// rotate the cron.log when it exceeds a size of 10 MB
$logfile = $conf['ispconfig_log_dir'].'/cron.log';
if(is_file($logfile) && filesize($logfile) > 10000000) {
exec("gzip -c $logfile > $logfile.1.gz");
exec("cat /dev/null > $logfile");
}
// rotate the auth.log when it exceeds a size of 10 MB $ispconfig_logfiles = array('ispconfig.log', 'cron.log', 'auth.log');
$logfile = $conf['ispconfig_log_dir'].'/auth.log'; foreach($ispconfig_logfiles as $ispconfig_logfile) {
if(is_file($logfile) && filesize($logfile) > 10000000) { $ispconfig_logfile = escapeshellcmd($conf['ispconfig_log_dir'].'/'.$ispconfig_logfile);
exec("gzip -c $logfile > $logfile.1.gz"); // rename older files (move up by one)
exec("cat /dev/null > $logfile"); while($num >= 1 && is_file($ispconfig_logfile . '.' . $num . '.gz')) {
rename($ispconfig_logfile . '.' . $num . '.gz', $ispconfig_logfile . '.' . ($num + 1) . '.gz');
$num--;
}
// compress current logfile
if(is_file($ispconfig_logfile)) {
exec("gzip -c $ispconfig_logfile > $ispconfig_logfile.1.gz");
exec("cat /dev/null > $ispconfig_logfile");
}
// remove older logs
while(is_file($ispconfig_logfile . '.' . $num . '.gz')) {
@unlink($ispconfig_logfile . '.' . $num . '.gz');
$num++;
}
} }
//###################################################################################################### //######################################################################################################
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment