diff --git a/cron.php b/cron.php index 747d07a..b05bc3f 100644 --- a/cron.php +++ b/cron.php @@ -109,13 +109,27 @@ function run__cronjobs_cache_cleanup() { unlink($cache_dir.'/'.$fl); } } - $dir = $GLOBALS['appconf']['data_dir'].'/cron/db'; + $crondb_dir = $GLOBALS['appconf']['data_dir'].'/cron/db'; + foreach (scandir($crondb_dir) as $fl) { + if (in_array($fl, ['.','..'])) + continue; + $cron_file = $crondb_dir.'/'.$fl; + $data = @unserialize(file_get_contents($cron_file)); + if ($data === false || !isset($data['last_accessed'])) + continue; + $ms = time() - $data['last_accessed']; + $days_diff = intval($ms / 60 / 60 / 24); + if ($days_diff >= 7) { + logi('CACHE-CLEANUP remove cron/db cache creator file: '.$fl); + unlink($cron_file); + } + } foreach ($others as $fl) { $ps = explode(',',$fl); if (count($ps) === 2 && $ps[1] === 'always') { $id = $ps[0]; $contains = false; - foreach (scandir($dir) as $f) { + foreach (scandir($crondb_dir) as $f) { if (in_array($f, ['.','..'])) continue; if (strpos($f, ','.$id.',') !== false) {