Linux定期清理日志脚本



Linux定期清理日志脚本
 
1、编写清理日志脚本clearlog.sh
 
#!/bin/sh
find /newdisk/ss/mg/log -mtime +1 -name "*.log" -exec rm {} \;
find /newdisk/ss/msu/log -mtime +1 -name "*.log" -exec rm {} \;
 
2、给脚本增加可执行权限
  www.2cto.com  
我的脚本默认放在/opt/下
 
chmod 755 /opt/clearlog.sh
 
3、加入定时执行任务,定时执行脚本
切换到root用户
使用crontab 命令建立定时执行
 
命令:crontab –e
加入行:*/10 * * * * /opt/clearlog.sh
改行含义为每10分执行/usr/clearlog.sh脚本一次
 

相关内容

    暂无相关文章