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
精彩评论