File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
server/lib/classes/cron.d Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -137,11 +137,18 @@ public function onRunJob() {
137137 }
138138 }
139139
140- // rotate and compress the error.log when it exceeds a size of 10 MB
141- $ logfile = escapeshellcmd ($ rec ['document_root ' ].'/ ' . $ log_folder . '/error.log ' );
142- if (is_file ($ logfile ) && filesize ($ logfile ) > 10000000 ) {
143- exec ("gzip -c $ logfile > $ logfile.1.gz " );
144- exec ("cat /dev/null > $ logfile " );
140+ // rotate and compress the error.log
141+ $ error_logfile = escapeshellcmd ($ rec ['document_root ' ].'/ ' . $ log_folder . '/error.log ' );
142+ // rename older files (move up by one)
143+ $ num = $ log_retention ;
144+ while ($ num >= 1 && is_file ($ error_logfile . '. ' . $ num . '.gz ' )) {
145+ rename ($ error_logfile . '. ' . $ num . '.gz ' , $ error_logfile . '. ' . ($ num + 1 ) . '.gz ' );
146+ $ num --;
147+ }
148+ // compress current logfile
149+ if (is_file ($ error_logfile )) {
150+ exec ("gzip -c $ error_logfile > $ error_logfile.1.gz " );
151+ exec ("cat /dev/null > $ error_logfile " );
145152 }
146153
147154 // delete logfiles after x days (default 30)
You can’t perform that action at this time.
0 commit comments