批量创建并删除日志文件

按照下图创建日志文件:

批量创建日志文件
使用脚本创建

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`

个人比较倾向于 用反引号这个

猜你喜欢

转载自www.cnblogs.com/heqiuyu/p/10372037.html