Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

4.17. Cron

4.17.1. Vixie cron 和 Cronie

红帽企业版 Linux 6 包括 cronie 软件包作为 vixie-cron 的替代。这两个软件包之间主要的区别在于日常工作(日、周、月)如何完成。Cronie 使用 /etc/anacrontab 文件,默认如下所示:
# 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
这些常规任务将每天在 03:00-22:00 时间段执行一次,包括随机延迟。例如:cron.daily 将有 5 分钟强制延迟加上 0-45 分钟的随机延迟。您还可运行没有延迟的任务,在 4 到 5 之间:
RANDOM_DELAY=0 # or do not use this option at all

START_HOURS_RANGE=4-5

# 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
cronie 特性包括:
  • /etc/anacrontab 中启动任务的随机延迟。
  • /etc/anacrontab 中定义的常规任务时间段。
  • 每个 cron 表有其使用 CRON_TZ 变量定义的时区。
  • 默认情况下 cron 守护进程在不通知的情况下检查表格更改。
关于 cronie and cronie-anacron 的进一步信息,请参考《红帽企业版 Linux 部署指南》。