Delete over 14 Days Untouched Data, Automatically

如果有些暫存的資料夾. 定時想清理就可以用下列命令. 而我是比較懶惰. 我將指令放在 cron table裡面. 每天晚上凌晨自己讓電腦執行.

crontab -e

0 0 * * * find /scratch/ -mindepth 2 -maxdepth 5 -mtime +14 -exec rm -rf {} \;

上面的指令會把 /scratch/ 目錄內超過14天沒更新的資料清除. 且他會自己爬目錄爬五層.

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.