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<span id="_xhe_cursor"></span>
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

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章