什么时候cron.daily
(和.weekly
和.hourly
)中的条目运行,并且是可configuration的?
我还没有find一个明确的答案,并希望有一个。
我正在运行RHEL5和CentOS 4,但对于其他发行版/平台也会很好。
对于你提到的分配:
在CentOS 5.4上(对于RHEL5应该是一样的)
grep run-parts /etc/crontab 01 * * * * root run-parts /etc/cron.hourly 02 4 * * * root run-parts /etc/cron.daily 22 4 * * 0 root run-parts /etc/cron.weekly 42 4 1 * * root run-parts /etc/cron.monthly
所以cron.daily在凌晨04:02运行。
同样在CentOS 4.8
从手册页:
Cron also searches for /etc/anacrontab
/etc/anacrontab
在我的系统(Fedora 12)中:
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
另见man anacrontab
对于CentOS 6,您需要grep / etc / anacrontab,如果服务器/笔记本电脑/ dekstop / etc已被closures,则答案会有所不同。
cat /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
所以,在3AM和10PM之间的时间(重新启动之后,机器启动5分钟之后^^),运行/etc/cron.daily。 如果没有重新启动,作业应该在3点05分以上运行。
** As defined by START_HOURS_RANGE ^^ As defined by FIELD_TWO (ie the 5 after the 1 in the cron.daily line) ++ plus a random time between 0 and 45 minutes as defined by RANDOM_DELAY
参考: http : //linux.die.net/man/5/anacrontab
对于SuSE系统(特别是SLES 11.1和openSuSE 10.3), /etc/ cron.daily脚本的每日运行时间由/ etc / sysconfig / cron文件中设置的DAILY_TIMEvariables的值控制。
如果未设置DAILY_TIMEvariables,则默认为:(上次引导时间+ 15分钟)。
在Ubuntu上,您会从configuration的位置find文件/ etc / crontab。 我想这是在RH和Centos上类似的东西。
CentOS6.x / RedHat6.x默认安装包cronie-anacron。 你必须:
yum安装cronie-noanacron
yum擦除cronie-anacron
然后,您现在有/etc/cron.d/dailyjobs来为您的每日,每周和每月工作configuration最佳的计划时间。
我使用Slackware(14.0),并没有/etc/crontab
。 此外, anacron
不是分配的一部分。
我的系统上的解决scheme与以root身份运行crontab -l
一样简单:
root@flea:~# crontab -l # If you don't want the output of a cron job mailed to you, you have to direct # any output to /dev/null. We'll do this here since these jobs should run # properly on a newly installed system. If a script fails, run-parts will # mail a notice to root. # # Run the hourly, daily, weekly, and monthly cron jobs. # Jobs that need different timing may be entered into the crontab as before, # but most really don't need greater granularity than this. If the exact # times of the hourly, daily, weekly, and monthly cron jobs do not suit your # needs, feel free to adjust them. # # Run hourly cron jobs at 47 minutes after the hour: 47 * * * * /usr/bin/run-parts /etc/cron.hourly 1> /dev/null # # Run daily cron jobs at 4:40 every day: 40 4 * * * /usr/bin/run-parts /etc/cron.daily 1> /dev/null # # Run weekly cron jobs at 4:30 on the first day of the week: 30 4 * * 0 /usr/bin/run-parts /etc/cron.weekly 1> /dev/null # # Run monthly cron jobs at 4:20 on the first day of the month: 20 4 1 * * /usr/bin/run-parts /etc/cron.monthly 1> /dev/null
就Solaris而言,没有这样的设施。 只需使用常规的crontab条目进行日常任务即可。
从我的Ubuntu 9.10系统上的/etc/anacrontab
:
1 5 cron.daily nice run-parts --report /etc/cron.daily 7 10 cron.weekly nice run-parts --report /etc/cron.weekly @monthly 15 cron.monthly nice run-parts --report /etc/cron.monthly