2603.8 purging old records

This commit is contained in:
2026-03-13 16:01:19 -04:00
parent 86573769ca
commit 1e57388299
8 changed files with 191 additions and 17 deletions

25
cron/purge.php Executable file
View 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);