Linux定时shell脚本

明天星期天,不对,应该说今天,有一个要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

猜你喜欢

转载自blog.csdn.net/fengaodlw/article/details/46846355