按照下圖創建日誌文件:
使用腳本創建
for n in `seq 14`;
do
date -s "2016/03/$n";
touch access_www_$(date +%F).log;
done
~
並刪除7天之前的文件:當然所有的就都刪除乾淨了:
三種方法都可以:
[root@centos heqiuyu]# find /root/heqiuyu -type f -mtime +7 | xargs rm -f
[root@centos heqiuyu]# find /root/heqiuyu -type f -mtime +7 -exec rm -f {} \;
[root@centos heqiuyu]# rm -f `find /root/heqiuyu -type f -mtime +7`
個人比較傾向於 用反引號這個