From db72533233138a5eff3170884c6f95330da8a2df Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 13 Sep 2018 12:49:28 +0200 Subject: [PATCH] Added dbclean --- include/functions.php | 9 +++++++++ webcron.php | 2 ++ 2 files changed, 11 insertions(+) diff --git a/include/functions.php b/include/functions.php index c4dd404..f1c220b 100644 --- a/include/functions.php +++ b/include/functions.php @@ -87,4 +87,13 @@ function parse_config_type($type) { break; } return $r_var; +} + +function clean_database() { + global $db; + + $oldestrun = time() - (60 * 60 * 24 * get_configvalue('dbclean.expireruns')); + + $stmt = $db->prepare("DELETE FROM runs WHERE timestamp < ?"); + $stmt->execute(array($oldestrun)); } \ No newline at end of file diff --git a/webcron.php b/webcron.php index db390a7..20a8109 100644 --- a/webcron.php +++ b/webcron.php @@ -105,6 +105,8 @@ foreach ($results as $result) { $nosave = false; } +clean_database(); + unlink('/tmp/webcron.lock'); if(file_exists("cache/reboot.trigger")) {