centos 定时器
centos 定时器1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16Usage:
 crontab [options] file
 crontab [options]
 crontab -n [hostname]
Options:
 -u <user>  define user
 -e         edit user's crontab
 -l         list user's crontab
 -r         delete user's crontab
 -i         prompt before deleting
 -n <host>  set host in cluster to run users' crontabs
 -c         get host in cluster to run users' crontabs
 -s         selinux context
 -x <mask>  enable debugging
编辑定时任务:crontab -e
每分钟执行/var/monitor.sh脚本1
* * * * * /var/monitor.sh
|*|*|*|*|*|/var/monitor.sh|
—|—|—|—|—|—|
分钟|小时|日|月|星期|执行脚本|
* 代表每(分/时/日/月/星期)都执行
- 表示时间段,如 10-12
, 表示多个时间段或时间点 10,12,14-16
 /n 表示隔n的时间 */10 每隔10执行
| */10 | 10,12-14 | * | * | * | /var/monitor.sh | |
|---|---|---|---|---|---|---|
| 每隔10分钟 | 10点和12点到14点 | 日 | 月 | 星期 | 执行脚本 | 
编辑好后重启服务使任务生效service crond restart
查看定时服务状态service crond status
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 张拓的博客!






