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/cron_daily.php |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

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