Linux/シェルスクリプト/n日以上前に作成されたファイルを削除する の変更点
- 追加された行はこの色です。
- 削除された行はこの色です。
- Linux/シェルスクリプト/n日以上前に作成されたファイルを削除する へ行く。
- Linux/シェルスクリプト/n日以上前に作成されたファイルを削除する の差分を削除
以下のようなコマンドで手軽に数日以上前に作成したファイルを削除できます。 find /home/postgres/dbbackup -type f -daystart -mtime +n |xargs /bin/rm -f find (場所) -type f -daystart -mtime +n |xargs /bin/rm -f 上記の-mtime +n の n に日数を指定できます。 cron を使って毎日実行すれば、毎日ディレクトリを監視して一定期間を過ぎたファイルを消す、という使い方ができます。 (シェル例) #!/bin/sh find . -type f -daystart -mtime +15 |xargs /bin/rm -f find /usr/local/tomcat/logs -type f -daystart -mtime +15 |xargs /bin/rm -f -参考URL:Landscape - エンジニアのメモ --http://sonic64.com/2003-04-16.html