开发者

Unix shell script to delete older log files

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜