In this case, I wanted to delete files from /tmp that weren't being removed automatically because the process that created them
took a long time to terminate. The following command deletes all files suffixed in .partd
, as well as any files in folders suffixed
by .partd
(what I wanted - note the -type f
flag means files only, so not directories) which were last accessed more than 30
minutes ago. The flag -amin +30
indicates last accessed more than 30 minutes ago, and -delete
means delete the files found.
find /tmp/*.partd -amin +30 -type f -delete
I used cron to run this job every half hour. Cron syntax can be more complicated than this, but for this simple example the line in the crontab file was
0,30 * * * * find /tmp/*.partd -amin +30 -type f -delete >/dev/null 2>&1
The redirection at the end is for the output of the command.
crontab -e
creates / edits a crontab file for the current user