How to remove files that are over 1 day old

/ Published in: Bash
Save to your folder(s)

A one-liner to remove any temporary files modified over one day ago. Removes files from /tmp/
Run without the '-exec rm {} \;' part to check that it is matching the right set of files - this can be dangerous if run by root!
If you want to remove files modified today, change +1 to -1
This can be useful to add into crontab though

Copy this code and paste it in your HTML
  1. find /tmp/ -type f -mtime +1 -exec rm {} \;

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.