Add script to clear old autosaved graphs

This commit is contained in:
Oleg Sh
2025-01-07 19:51:43 +01:00
parent c85469fa08
commit 159c87c041
2 changed files with 24 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
<?php
include ("../core/config/main.php");
$dirName = "../" . $g_config['graphSavePath'] . 'autosave/*';
$days_to_remove = 14;
//echo($dirName . "<br>");
$files = glob($dirName, 0);
$count = 0;
foreach ($files as $file)
{
$fileAgeInDays = (time() - filemtime($file)) / (3600 * 24);
if ($fileAgeInDays > $days_to_remove)
{
if (unlink($file))
{
echo($file . " " . $fileAgeInDays . "<br>");
$count = $count + 1;
}
}
}
echo("Deleted " . $count . " graphs");
?>