cron crontab anacron anacrontab Linux下的计划任务

命令/进程 程序位置 读取文件 日志

crond

 

crontab

anacron

/etc/rc.d/init.d(/etc/init.d)

/lib/systemd/system/crond.service

systemctl start crond.service

/var/spool/cron/ - crontab命令创建以用户名命名的corntables

/etc/crontab --> /etc/anacrontab(默认转而使用后者)

/etc/cron.d/ - 为不同用户保存的系统cronjobs

1. 读取这些文件的修改时间

2. 读取日志文件

3. 修改文件后不需要重启crond,系统自动根据上面两条来更新

 

/etc/cron.allow

/etc/cron.dely - 这两个文件不存在时,只有super user才能用crontab

 

crontab [-u user] -e | -l 编结,列出指定用户的cron

/var/log/cron

# vim /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

前五个时间日期域的有效格式可以是:
* - 表示有效值范围内的任务值
列表 - 是用逗号分隔的多个值,可以包含区间。例:"1,3,7" 或 "1,2,4-8,12-23"
频率 - 如分钟域为“*/2”或 "0-59/2" 表示每两分钟执行一次
月和星期 - 可以是英语单词的前三个字母,不区分大小写

# vim /etc/anacrontab

# /etc/anacrontab: configuration file for anacron

# See anacron(8) and anacrontab(5) for details.

SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=45
# the jobs will be started during the following hours only
START_HOURS_RANGE=3-22

#period in days   delay in minutes   job-identifier   command
1       5       cron.daily              nice run-parts /etc/cron.daily
7       25      cron.weekly             nice run-parts /etc/cron.weekly
@monthly 45     cron.monthly            nice run-parts /etc/cron.monthly

 

 

 

 

 

你可能感兴趣的:(DevOps)