Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Is there a way to clean a directory using PHP after a certain amount of days? I'd like to put the amount of days into a $Cleanup variable? I've tried and not been able to get it working.

share|improve this question

1 Answer 1

You would need to set a cron job (scheduled task) you set these via the server control panel or with ssh to the server.

You would basically make a script that contained the code to delete all items in the directory and tell the cron task the path of that script, then tell it to run periodically.

share|improve this answer
    
What script would I need to add to delete files after 14 days? –  Iestyn Oct 1 '13 at 23:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.