Welcome Guest, Not a member yet? Register   Sign In
Delete file after 24 hours?
#1

[eluser]Unknown[/eluser]
I want to create a script that will move some files into a temporary location, then delete those files after some period of time, like 24 hours. Do I need to use Cron to do this, or is there some clever way of using PHP / CodeIgniter to handle this for me?
#2

[eluser]pickupman[/eluser]
Cron would be the way to go if it has to be on exact time increments, otherwise you could extend your controller class. Add a function call that deletes files before the time interval in your constructor. When ever a page is called, the controller will delete any files 24hours prior to now.

Take a look at one of the cache libraries out there. They basically automatically delete cache files after a set time interval. Search for Phil Sturgeon's cache library.




Theme © iAndrew 2016 - Forum software by © MyBB