[root@localhost ~]# anacron [選項] [工作名]
這里的工作名指的是依據 /etc/anacrontab 文件中定義的工作名。表 1 羅列出了此命令常用的幾個選項及各自的功能。| 選項 | 功能 |
|---|---|
| -f | 強制執行相關工作,忽略時間戳。 |
| -u | 更新 /var/spool/anacron/cron.{daily,weekly,monthly} 文件中的時間戳為當前日期,但不執行任何工作。 |
| -s | 依據 /etc/anacrontab 文件中設定的延遲時間順序執行工作,在前一個工作未完成前,不會開始下一個工作。 |
| -n | 立即執行 /etc/anacrontab 中所有的工作,忽略所有的延遲時間。 |
| -q | 禁止將信息輸出到標準錯誤,常和 -d 選項合用。 |
[root@localhost ~]# vi /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
#前面的內容和/etc/crontab類似
#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_H0URS_RANGE=3-22
#fanacron的執行時間范圍是3:00~22:00
#period in days delay in minutes job-identifier command
1 5 cron.daily nice run-parts /etc/cron.daily
#每天開機 5 分鐘后就檢查 /etc/cron.daily 目錄內的文件是否被執行,如果今天沒有被執行,那就執行
7 25 cron.weekly nice run-parts /etc/cron.weekly
#每隔 7 天開機后 25 分鐘檢查 /etc/cron.weekly 目錄內的文件是否被執行,如果一周內沒有被執行,就會執行
©monthly 45 cron.monthly nice run-parts /etc/cron.monthly
#每隔一個月開機后 45 分鐘檢查 /etc/cron.monthly 目錄內的文件是否被執行,如果一個月內沒有被執行,那就執行
[root@localhost ~] # vi /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=0
#把最大隨機廷遲改為0分鐘,不再隨機廷遲
# the jobs will be started during the following hours only START_HOORS_RANGE=3-5
#執行時間范圍為03:00—05:00
#period in days delay in minutes job-identifier command
1 0 cron.daily nice run-parts /etc/cron.daily
7 0 cron.weekly nice run-parts /etc/cron.weekly
@monthly 0 cron.monthly nice run-parts /etc/cron.monthly
#把強制延遲也改為0分鐘,不再強制廷遲
新聞熱點
疑難解答