【Linux】linux定时清除N天之前的文件,一般用于清除日志文件

定时清除,使用linux的crontab定时任务

*  *  *  *  *  command 
分 时 日 月 周 命令 

清楚日志脚本

find /root/smsp/logs/ -mtime +25 -name "zk*.log*" -exec rm -rf {} \;
删除/root/smsp/logs目录下25天前修改过的文件,文件格式zk*.log*



每天8点执行清楚日志的脚本

0 8 * * * sh /root/sms/logDel.sh






猜你喜欢

转载自blog.csdn.net/chiweitree/article/details/52291200