LINUX操作系统定时清理日志

LINUX操作系统定时清理日志

1        建立清除日志脚本

使用vi 编辑清除日志脚本

命令:vi clearlog.sh

加入行:find /tongeasy/dev/log  -mtime +10  -name "ULOG.*" -exec rm {} \;

该行含义为在/tongeasy/dev/log目录找到10天前且为ULOG.开头的文件,并删除

保存退出vi 编辑器

2        清除日志脚本加入执行权限

使用chmod命令

命令:chmod +x clearlog.sh

 

3        加入定时执行任务,定时执行脚本

切换到root用户

使用crontab 命令建立定时执行

命令:crontab –e

加入行:0 0 * * * /usr/clearlog.sh

改行含义为每天0点0分执行/usr/clearlog.sh脚本

转自:http://hi.baidu.com/wudengke213/item/86e47346f53d4ad0c0a5926d

posted @ 2013-07-01 15:52  simon1024  阅读(251)  评论(0)    收藏  举报