anacron
anacronとは?
指定したスケジュールにランダムな遅延を挿入してジョブを実行する機能。
指定した時刻に実行できなかった場合、実行できなかったジョブを再実行する機能がある。
/etc/anacrontab でのみジョブの指定が可能で、rootユーザでしか設定できない。
デーモンプロセスは存在しない。
動作するのは3時~22時くらいの間のみ。(設定で変更可能)
anacronの起動の流れ
crondデーモン
→/etc/crond/0hourly
→/etc/cron.hourly/0anacron
→/usr/sbin/anacron
→/etc/anacrontab
→/etc/cron.daily、cron.weekly、cron.monthly
※crondから呼び出されるのでcrondが動作していないとanacronも動作しない
CentOS5の場合/etc/crontabから/etc/cron.hourly、/etc/cron.daily、cron.weekly、cron.monthly呼ばれていた
ジョブの実行履歴が/var/spool/anacron/cron.xxxに記載される
【/etc/crond/0hourlyの設定例】
01 * * * * root run-parts /etc/cron.hourly
【/etc/anacrontabの例】
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
参考