File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
server/lib/classes/cron.d Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,30 @@ public function onRunJob() {
112112 exec ("gzip -c $ logfile > $ logfile.gz " );
113113 unlink ($ logfile );
114114 }
115+
116+ $ cron_logfiles = array ('cron.log ' , 'cron_error.log ' , 'cron_wget.log ' );
117+ foreach ($ cron_logfiles as $ cron_logfile ) {
118+ $ cron_logfile = escapeshellcmd ($ rec ['document_root ' ].'/ ' . $ log_folder . '/ ' . $ cron_logfile );
119+
120+ // rename older files (move up by one)
121+ $ num = 7 ;
122+ while ($ num >= 1 && is_file ($ cron_logfile . '. ' . $ num . '.gz ' )) {
123+ rename ($ cron_logfile . '. ' . $ num . '.gz ' , $ cron_logfile . '. ' . ($ num + 1 ) . '.gz ' );
124+ $ num --;
125+ }
126+
127+ // compress current logfile
128+ if (is_file ($ cron_logfile ) && filesize ($ cron_logfile ) > 10000000 ) {
129+ exec ("gzip -c $ cron_logfile > $ cron_logfile.1.gz " );
130+ exec ("cat /dev/null > $ cron_logfile " );
131+ }
132+ // remove older logs
133+ $ num = 7 ;
134+ while (is_file ($ cron_logfile . '. ' . $ num . '.gz ' )) {
135+ @unlink ($ cron_logfile . '. ' . $ num . '.gz ' );
136+ $ num ++;
137+ }
138+ }
115139
116140 // rotate and compress the error.log when it exceeds a size of 10 MB
117141 $ logfile = escapeshellcmd ($ rec ['document_root ' ].'/ ' . $ log_folder . '/error.log ' );
You can’t perform that action at this time.
0 commit comments