您的位置:首页 > 运维架构 > Shell

Linux定时shell脚本

2015-07-12 00:33 507 查看
明天星期天,不对,应该说今天,有一个要11点处理的事情,星期天嘛,当然是想好好休息一下,睡个懒觉了。所以写了一个简单的脚本,来完成任务。

刚好有时间,顺便记录一下:

1.编写shell脚本

vi /root/sh/crond.sh

脚本内容:

#!/bin/sh

cd /root/task/bin/

./stop.sh

2.修改权限

chmod +x /root/sh/crond.sh

3.增加/etc/crontab

0 11 12 7 * root /root/sh/crond.sh

格式说明如下:

# Example of job definition:

# .---------------- minute (0 - 59)

# | .------------- hour (0 - 23)

# | | .---------- day of month (1 - 31)

# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...

# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat

# | | | | |

# * * * * * user-name command to be executed

4.重启crond服务

/etc/init.d/crond restart

5.查看脚本执行情况

/var/spool/mail/root
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: