From: Will Budic Date: Tue, 7 Jan 2020 23:14:13 +0000 (+1100) Subject: added removeOldSessions subrotine. X-Git-Url: https://lifelog.hopto.org/gitweb/?a=commitdiff_plain;h=2c15a5ecbc6628727ba1db09b71dd61a857b8f0a;p=LifeLog.git added removeOldSessions subrotine. --- diff --git a/htdocs/cgi-bin/system/modules/Settings.pm b/htdocs/cgi-bin/system/modules/Settings.pm index ee87226..ec4b6c5 100644 --- a/htdocs/cgi-bin/system/modules/Settings.pm +++ b/htdocs/cgi-bin/system/modules/Settings.pm @@ -170,4 +170,17 @@ sub toLog { # } } +sub removeOldSessions { + opendir(DIR, $LOG_PATH); + my @files = grep(/cgisess_*/,readdir(DIR)); + closedir(DIR); + my $now = time - (24 * 60 * 60); + foreach my $file (@files) { + my $mod = (stat("$LOG_PATH/$file"))[9]; + if($mod<$now){ + unlink "$LOG_PATH/$file"; + } + } +} + 1; \ No newline at end of file