From 630023aef3265412b954614fc450768fad8a1e04 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 18 Mar 2014 14:13:27 +0000 Subject: [PATCH] Updated dail schedule to remove old syslog and eventlog entries --- daily.php | 17 +++++++++++++++++ daily.sh | 3 +++ includes/defaults.inc.php | 4 ++++ 3 files changed, 24 insertions(+) diff --git a/daily.php b/daily.php index 22ac1e47e..ff8644a68 100644 --- a/daily.php +++ b/daily.php @@ -7,9 +7,26 @@ include('includes/defaults.inc.php'); include('config.php'); +include_once("includes/definitions.inc.php"); +include("includes/functions.php"); $options = getopt("f:"); if ( $options['f'] === 'update') { echo $config['update']; } +if ( $options['f'] === 'syslog') { + if ( is_numeric($config['syslog_purge'])) { + if ( dbDelete('syslog', "timestamp < DATE_SUB(NOW(), INTERVAL ? DAY)", array($config['syslog_purge'])) ) { + echo 'Syslog cleared for entries over ' . $config['syslog_purge'] . " days\n"; + } + } +} +if ( $options['f'] === 'eventlog') { + if ( is_numeric($config['eventlog_purge'])) { + if ( dbDelete('eventlog', "datetime < DATE_SUB(NOW(), INTERVAL ? DAY)", array($config['eventlog_purge'])) ) { + echo 'Eventlog cleared for entries over ' . $config['eventlog_purge'] . " days\n"; + } + } +} + ?> diff --git a/daily.sh b/daily.sh index a02a6846b..3d612727f 100644 --- a/daily.sh +++ b/daily.sh @@ -3,3 +3,6 @@ if [ $(php daily.php -f update) -eq 1 ]; then git pull --no-edit --quiet fi + +php daily.php -f syslog +php daily.php -f eventlog diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 4ed8388e4..3403c30ad 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -566,4 +566,8 @@ $config['modules_compat']['rfc1628']['poweralert'] = 1; # Enable daily updates $config['update'] = 1; +# Purge syslog and eventlog +$config['syslog_purge'] = 30; # Number in days of how long to keep syslog entries for. +$config['eventlog_purge'] = 30; # Number in days of how long to keep eventlog entries for. + ?>