首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

Linux 定期清算日志脚本

2012-10-21 
Linux 定期清理日志脚本1、编写清理日志脚本clearlog.sh#!/bin/shfind /newdisk/ss/mg/log -mtime 1 -name

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、给脚本增加可执行权限

我的脚本默认放在/opt/下

chmod 755 /opt/clearlog.sh


3、加入定时执行任务,定时执行脚本
切换到root用户
使用crontab 命令建立定时执行
命令:crontab –e
加入行:*/10 * * * * /opt/clearlog.sh
改行含义为每10分执行/usr/clearlog.sh脚本一次

热点排行