Skip to content

Commit 3e0034c

Browse files
committed
Implemented: FS#1109 - Rotate website error logs and ispconfig log
1 parent 2a704f6 commit 3e0034c

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

server/conf/vhost.conf.master

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
ServerAdmin webmaster@<tmpl_var name='domain'>
2424

2525
ErrorLog /var/log/ispconfig/httpd/<tmpl_var name='domain'>/error.log
26+
2627
<tmpl_if name='errordocs'>
2728

2829
ErrorDocument 400 /error/400.html

server/cron_daily.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,13 @@ function setConfigVar( $filename, $varName, $varValue ) {
207207
exec("gzip -c $logfile > $logfile.gz");
208208
unlink($logfile);
209209
}
210+
211+
// rotate and compress the error.log when it exceeds a size of 10 MB
212+
$logfile = escapeshellcmd($rec["document_root"].'/log/error.log');
213+
if(is_file($logfile) && filesize($logfile) > 10000000) {
214+
exec("gzip -c $logfile > $logfile.1.gz");
215+
exec("cat /dev/null > $logfile");
216+
}
210217

211218
// delete logfiles after 30 days
212219
$month_ago = date("Ymd",time() - 86400 * 30);
@@ -216,6 +223,17 @@ function setConfigVar( $filename, $varName, $varValue ) {
216223
}
217224
}
218225

226+
#######################################################################################################
227+
// Rotate the ispconfig.log file
228+
#######################################################################################################
229+
230+
// rotate the ispconfig.log when it exceeds a size of 10 MB
231+
$logfile = '/var/log/ispconfig/ispconfig.log');
232+
if(is_file($logfile) && filesize($logfile) > 10000000) {
233+
exec("gzip -c $logfile > $logfile.1.gz");
234+
exec("cat /dev/null > $logfile");
235+
}
236+
219237
#######################################################################################################
220238
// Cleanup website tmp directories
221239
#######################################################################################################

0 commit comments

Comments
 (0)