I would say use a chronjob if you can , personally I would do it like so: 1.Create a database entry when the files created/uploaded containing the unixtime stamp of the file upload date. 2.Have a chronjob running at whatever frequency you require. 3.Inside the chronjob do this: check the result of current unix time stamp - database entry we made in step 1 If the result of this sum is more than 30 (or however many seconds/minutes to wait before deletion) then delete the file. This will not work great if you need extreme accuracy with deletion times but as a chronjob that runs say hourly it would be fine.
You can do it through a simple shell script; E.G the following will delete files that are 7 days old. find . -mtime 7 -print | xargs rm Code (markup): NOTE: Be sure to keep backups of your files. The reason should be obvious.
You could try the following, however you'd need to place this within a global file which would be run regulary...for it to take effect. <?php //time interval for deletion to occur... $x = 30; //timestamp $current_time = time(); //the file you wish to delete $file_name = 'file.txt'; //timestamp $file_creation_time = filemtime($filename); //extract difference $difference = $current_time - $file_creation_time; //if difference = $x...then delete file if ($difference == $x) { unlink($file_name); } ?> PHP: