From 3e0034c1dc3eb944d4e275b62c314cf01dbeda96 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Tue, 29 Jun 2010 08:40:00 -0400
Subject: [PATCH] Implemented: FS#1109 - Rotate website error logs and ispconfig log
---
server/conf/vhost.conf.master | 1 +
server/cron_daily.php | 18 ++++++++++++++++++
2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/server/conf/vhost.conf.master b/server/conf/vhost.conf.master
index 5d5f5da..6c6d75e 100644
--- a/server/conf/vhost.conf.master
+++ b/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
diff --git a/server/cron_daily.php b/server/cron_daily.php
index b861558..dd32c46 100644
--- a/server/cron_daily.php
+++ b/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
#######################################################################################################
--
Gitblit v1.9.1