Issue
I want to delete a folder and its contents on my host if it is over a day old. The issue is that I have no experience on how to do this with a linux cron job. I should also say that i have looked at google and nothing comes up. I think this is a pretty simple question so please, help me out. Thanks
Solution
This should do it:
find /path/to/dir -maxdepth 0 -ctime +1 -exec rm -fr {} +
But be careful, and test it first outside of cron
, without the -exec
part, so you don't delete something else by accident.
Answered By - janos Answer Checked By - Dawn Plyler (WPSolving Volunteer)