Search code examples
cron

CRON to Clear out /tmp files older than 30min old


the servers root /tmp directory has been getting full with file uploads. These files should be removed once the upload is done, but in some cases it hasn't. As i investigate that issue. Im looking for a cron task to delete files that start 202 from the /tmp directory that's 30 minutes old that runs every 30 minutes.

So far, i have /30 * * * rm -rf /tmp/202*


Solution

  • Found this solution. Works pretty well.

    0 * * * *  find /tmp -regextype posix-egrep -regex '/tmp/[0-9]{8}-[0-9]{6}-.*-file-.*' -type f -mmin +60 -delete