版主说明:在linux下实现周期定时的执行脚本命令

Web开发网资料库

一:用vi 打开/etc/crontab,可以看到如下内容:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly

二:crontab 的格式如下
# r—-minute (0-59) -1 = each (*)
# | r—–hour (0-23) 25 for disable
# | | r——day of the month (1-31)
# | | | r——month (1-12)
# | | | | r——day of the week (1-7 monday=1)
# | | | | | r—— command to run ————->
# | | | | | |
# | | | | | |

三:举例-每天晚上2:25分重启机器

用vi编辑/etc/crontab,增加下面的内容:
25 2 * * * root /users/test/rebootMachine.sh
--在rebootMachine.sh先编辑下面的内容:init 6

 

访客统计:web counter