echo "Scanned ".(count($Folder)-2)." I-Nodes in ".(microtime(true)-$Before)." sec".PHP_EOL;
Ob das ausreicht haengt vom Einsatzzweck ab.Ansonsten kümmert sich PHP GC selbst um die Session-Files
session.gc_maxlifetime = 1440
Gwuerzt mit probabilistischer Loeschung, ja =)Das Zeugs ist wohl ein normaler Cronjob von PHP ...
Wozu verlinke ich hier eigentlich noch Dokumentationen, wenn sie eh keiner liest :-/Oder kann es sein, dass nur wenn der Endbenutzer die Seite nochmals aufruft und gc_maxlifetime überschritten wurde, dass dann die Session gelöscht wird?
Scanned in 240.62626195 sec
Scanned 186 I-Nodes in 240.713857889 sec
Scanned in 43.8853240013 sec
Scanned 195 I-Nodes in 43.8854169846 sec
Scanned in 2.52769708633 sec
Scanned 143 I-Nodes in 2.55781006813 sec
; The probability is calculated by using gc_probability/gc_divisor,
; e.g. 1/100 means there is a 1% chance that the GC process starts
; on each request.
[B]; This is disabled in the Debian packages, due to the strict permissions
; on /var/lib/php5. Instead of setting this here, see the cronjob at
; /etc/cron.d/php5, which uses the session.gc_maxlifetime setting below.[/B]
; php scripts using their own session.save_path should make sure garbage
; collection is enabled by setting session.gc_probability
;session.gc_probability = 0
session.gc_divisor = 100
; After this number of seconds, stored data will be seen as 'garbage' and
; cleaned up by the garbage collection process.
session.gc_maxlifetime = 1440
#!/usr/bin/php5
<?php
$Location = '/var/lib/php5/';
$DeleteOlderThan = 24;
$SleepFor = 250; //1000000 microseconds = 1 second
proc_nice(19);
$MaxModified = time() - $DeleteOlderThan * 60;
$Handle = opendir($Location);
while(($File = readdir($Handle)) !== false) {
if($File == '.' || $File == '..') continue;
if(!is_file($Location.$File)) continue;
if(file_ctime($Location.$File) < $MaxModified) unlink($Location.$File);
usleep($SleepFor);
}
?>