Cron job to delete files created before a specific time
I have this cron job to empty a temp folder I have once a day:
rm -rf /home/username/public_html/temp/*
I want this cron job to delete all files which created before the it will run with 5 minutes and up just to make sure that my script don't need these files anymore.
Let's say I set the cron job to run everyday at 10:00 AM .. I want it to delete all files in this folder which created before 09:55 AM
Thank you so much experts!
If you're using GNU find, try this:
find /home/username/public_html/temp -type f -mmin +5 -delete
Should also work with FreeBSD or many other versions of find.