How to delete files older than X hours

Does your find have the -mmin option? That can let you test the number of mins since last modification:

find $LOCATION -name $REQUIRED_FILES -type f -mmin +360 -delete

Or maybe look at using tmpwatch to do the same job. phjr also recommended tmpreaper in the comments.


Here is the approach that worked for me (and I don't see it being used above)

$ find /path/to/the/folder -name '*.*' -mmin +59 -delete > /dev/null

deleting all the files older than 59 minutes while leaving the folders intact.


You could to this trick: create a file 1 hour ago, and use the -newer file argument.

(Or use touch -t to create such a file).