Hey guys, I needthis PHP cron job script which can automatically delete files within a partiuclar folder, after like 12 hours, corresponding to the 'Last Modified' Date of the file. Note: I'm NOT looking for cron to remove files every 12 hours.. $5 to someone who can code it
Here is the script: //$_SERVER['DOCUMENT_ROOT']=''; $path=$_SERVER['DOCUMENT_ROOT'].'/your_folder'; $now_minus_12h=time()-43200; $folder=dir($path); while ($entry = $folder->read()) { $file=$path.'/'.$entry; if (!is_dir($file)) { $modified=filemtime($file); if ($modified<$now_minus_12h) unlink($file); } } $folder->close(); Code (markup): Just set the cron to run every 5 or 10 minutes. Also you may have to manually set $_SERVER['DOCUMENT_ROOT']. Vilius smurfas666@hotmail.com