How to delete files older than X hours

bash

Solution

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.

Problem

I'm writing a bash script that needs to delete old files. It's currently implemented using : ``` find $LOCATION -name $REQUIRED_FILES -type f -mtime +1 -delete ``` This will delete of the files older than 1 day. However, what if I need a finer resolution that 1 day, say like 6 hours old? Is there a nice clean way to do it, like there is using find and -mtime?

Original source

Related problems