We Recommend

bash Cookbook: Solutions and Examples for bash Users bash Cookbook: Solutions and Examples for bash Users
bash Cookbook teaches shell scripting the way Unix masters practice the craft. It presents a variety of recipes and tricks for all levels of shell programmers so that anyone can become a proficient user of the most common Unix shell -- the bash shell -- and cygwin or other popular Unix emulation packages.


Posted By

wolfie on 08/28/07


Tagged

file Bash removal crontab


Versions (?)


How to remove files that are over 1 day old


Published in: Bash 


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

  1. find /tmp/ -type f -mtime +1 -exec rm {} \;

Report this snippet 

You need to login to post a comment.