定时删除log脚本
#!/bin/sh
cd ..
pwd ;
declare -i days=30
echo This script is remove old logfile $days . you can change days variable turning.
find ./ -mtime +$days -name "*.log" ;
echo 'remove...'
find ./ -mtime +$days -name "*.log" -exec rm -rf {} \;
chmod +x a.sh
添加计划任务
crontab -e
10 0 * * * /kfts/its/scripts/auto-del-30days-ago-log.sh >/dev/null 2>&1
参考:
Linux计划任务工具cron用法详解
http://yaksayoo.blog.51cto.com/510938/162062
Linux应用总结(1):自动删除n天前日志
http://www.cnblogs.com/peida/archive/2013/03/25/2980121.html
Linux Shell脚本教程
http://blog.51cto.com/zt/660