Cron - log retention should include the new app and audit logs tables too

This commit is contained in:
wrongecho 2025-01-14 17:48:42 +00:00
parent 34daca31b8
commit f774218b6d
2 changed files with 7 additions and 1 deletions

View File

@ -44,7 +44,7 @@ require_once "includes/inc_all_admin.php";
</div>
<div class="form-group">
<label>Log retention <small class="text-secondary">(The amount of days before audit logs are deleted during nightly cron)</small></label>
<label>Log retention <small class="text-secondary">(The amount of days before app/audit/auth logs are deleted during nightly cron)</small></label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-clock"></i></span>

View File

@ -130,6 +130,12 @@ mysqli_query($mysqli, "DELETE FROM remember_tokens WHERE remember_token_created_
// Cleanup old audit logs
mysqli_query($mysqli, "DELETE FROM logs WHERE log_created_at < CURDATE() - INTERVAL $config_log_retention DAY");
// Cleanup old app/debug logs
mysqli_query($mysqli, "DELETE FROM app_logs WHERE app_log_created_at < CURDATE() - INTERVAL $config_log_retention DAY");
// Cleanup old auth logs
mysqli_query($mysqli, "DELETE FROM auth_logs WHERE auth_log_created_at < CURDATE() - INTERVAL $config_log_retention DAY");
// Logging
// logAction("Cron", "Task", "Cron cleaned up old data");