9.3.14. 定时任务安排
使用 cron(8) 来进行定时任务安排。参见 crontab(1) 和 crontab(5).
你能够作为一个普通用户定时运行一个进程,比如, foo
使用 “crontab -e
“ 命令创建一个 crontab(5) 的文件 “/var/spool/cron/crontabs/foo
“。
这里是一个 crontab(5) 文件的列子。
# use /bin/sh to run commands, no matter what /etc/passwd says
SHELL=/bin/sh
# mail any output to paul, no matter whose crontab this is
MAILTO=paul
# Min Hour DayOfMonth Month DayOfWeek command (Day... are OR'ed)
# run at 00:05, every day
5 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1
# run at 14:15 on the first of every month -- output mailed to paul
15 14 1 * * $HOME/bin/monthly
# run at 22:00 on weekdays(1-5), annoy Joe. % for newline, last % for cc:
0 22 * * 1-5 mail -s "It's 10pm" joe%Joe,%%Where are your kids?%.%%
23 */2 1 2 * echo "run 23 minutes after 0am, 2am, 4am ..., on Feb 1"
5 4 * * sun echo "run at 04:05 every Sunday"
# run at 03:40 on the first Monday of each month
40 3 1-7 * * [ "$(date +%a)" == "Mon" ] && command -args
提示 | |
---|---|
对那些非连续运行的系统,安装 |
提示 | |
---|---|
对于定时系统维护脚本,你能够以root 账户定时运行,把这类脚本放入 “ |