[root@centos ~]# vi /etc/crontab |
#毎日1時1分に2ヶ月以上過ぎたログファイルを削除 1 1 * * * root /bin/find /var/www/html/syslog/ -name '*.log' -mtime +62 -delete |
あるディレクトリ内にある一定期間過ぎたファイルをしたい場合などはtmpwatchコマンドがお勧めです。
1時間過ぎた/tmp/以下のファイルを削除
[root@centos ~]# yum install tmpwatch |
-tオプションで確認する |
[root@centos ~]# tmpwatch -mt 1 /tmp/ |
実際に実行 |
[root@centos ~]# tmpwatch -m 1 /tmp/ |