2603.8 purging old records
This commit is contained in:
25
cron/purge.php
Executable file
25
cron/purge.php
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
/**
|
||||
* portspoof_concentrator – purge cron
|
||||
*
|
||||
* Deletes connections older than the retention_days setting.
|
||||
* Must be run from the command line — exits immediately if called over HTTP.
|
||||
*
|
||||
* Recommended crontab entry (once daily at 02:00):
|
||||
* 0 2 * * * /usr/bin/php /path/to/portspoof_concentrator/cron/purge.php >> /var/log/portspoof_concentrator/purge.log 2>&1
|
||||
*/
|
||||
|
||||
if (PHP_SAPI !== 'cli') {
|
||||
http_response_code(403);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
require_once __DIR__ . '/../includes/functions.php';
|
||||
|
||||
$days = max(1, (int)get_setting('retention_days', '7'));
|
||||
$deleted = purge_old_connections();
|
||||
|
||||
echo sprintf("[%s] Purged %d connection(s) older than %d day(s).\n",
|
||||
date('Y-m-d H:i:s'), $deleted, $days);
|
||||
Reference in New Issue
Block a user