首页 > 其他 > 详细

cron定时任务

时间:2020-04-15 00:45:38      阅读:78      评论:0      收藏:0      [点我收藏+]

[root@localhost cron.d]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

# For details see man 4 crontabs

# 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

其中一些特殊符号含义:

星号(*):代表所有可能的值,例如month字段如果是星号,则表示在满足其它字段的制约条件后每月都执行该命令操作。

逗号(,):可以用逗号隔开的值指定一个列表范围,例如,“1,2,5,7,8,9”。

中杠(-):可以用整数之间的中杠表示一个整数范围,例如“2-6”表示“2,3,4,5,6”。

正斜线(/):可以用正斜线指定时间的间隔频率,例如“0-23/2”表示每两小时执行一次。同时正斜线可以和星号一起使用,例如*/10,如果用在minute字段,表示每十分钟执行一次。

 

/etc/cron.d 和/etc/crontab 的区别:

简单来说,/etc/cron.d 下的定时任务是需要选用户的,eg:*/1 * * * * root  /usr/local/sbin/scripts/test.sh

而/etc/crontab 下的定时任务是,eg:*/1 * * * * /usr/local/sbin/scripts/test.sh 

 

查看编辑命令:

1.crontab -l  ---》列出定时任务

技术分享图片

 

2.crontab -e ---》编辑定时任务

3.crontab -r ---》删除定时任务

 

cron定时任务

原文:https://www.cnblogs.com/oyaisusu/p/12702159.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!