开发者

Unix shell script to delete older log files

开发者 https://www.devze.com 2023-02-17 21:51 出处:网络
Could someo开发者_JS百科ne please give me the command to delete log files before today (except today and yesterday) date?You can use find with the -mtime option to get a list of files modified more th

Could someo开发者_JS百科ne please give me the command to delete log files before today (except today and yesterday) date?


You can use find with the -mtime option to get a list of files modified more than N days ago.

For example:

find . -maxdepth 1 -name '*.txt' -mtime +2

will give you all the *.txt files in the current directory older than 48 hours.

You can add -delete to actually get rid of them.


find /path/to/files* -mtime +2 -delete
0

精彩评论

暂无评论...
验证码 换一张
取 消