Ric*_*way 174
对于您提到的发行版:
在 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
Run Code Online (Sandbox Code Playgroud)
所以 cron.daily 在凌晨 04:02 运行。
在 CentOS 4.8 上相同
leo*_*loy 85
从手册页:
Run Code Online (Sandbox Code Playgroud)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
Run Code Online (Sandbox Code Playgroud)
也可以看看 man anacrontab
Spe*_*hal 48
对于 CentOS 6,您需要 grep /etc/anacrontab 并且如果 server/laptop/dekstop/etc 是否已关闭,答案会有所不同。
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
Run Code Online (Sandbox Code Playgroud)
因此,在凌晨 3 点到晚上 10 点**(重新启动后和机器启动 5 分钟后^^)之间,运行 /etc/cron.daily。如果没有重新启动,作业应该在 3:05AM++ 运行。
** As defined by START_HOURS_RANGE
^^ As defined by FIELD_TWO (i.e. the 5 after the 1 in the cron.daily line)
++ plus a random time between 0 and 45 minutes as defined by RANDOM_DELAY
Run Code Online (Sandbox Code Playgroud)
参考:http : //linux.die.net/man/5/anacrontab
小智 16
对于 SuSE 系统(特别是 SLES 11.1 和 openSuSE 10.3),/etc/ cron.daily脚本的每日运行时间由/etc/sysconfig/cron文件中设置的DAILY_TIME变量的值控制。
如果未设置 DAILY_TIME 变量,则默认为:(上次启动时间 + 15 分钟)。
Sve*_*ven 10
在 Ubuntu 上,您会找到一个文件 /etc/crontab,它是从那里配置的。我想它在 RH 和 Centos 上是类似的。
小智 6
CentOS6.x/RedHat6.x 默认安装 cronie-anacron 软件包。你必须:
yum 安装 cronie-noanacron
百胜擦除 cronie-anacron
然后,您现在拥有 /etc/cron.d/dailyjobs 来为您的每日、每周和每月工作配置最佳计划时间。
小智 5
我使用 Slackware (14.0),但没有/etc/crontab. 此外,anacron不是发行版的一部分。
我系统上的解决方案就像crontab -l以 root身份运行一样简单:
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
Run Code Online (Sandbox Code Playgroud)