Когда выполняются записи в cron.daily(и .weeklyи .hourly), и настраивается ли это?
Я не нашел однозначного ответа на этот вопрос и надеюсь, что он есть.
Я использую RHEL5 и CentOS 4, но для других дистрибутивов / платформ тоже было бы неплохо.
Когда выполняются записи в cron.daily(и .weeklyи .hourly), и настраивается ли это?
Я не нашел однозначного ответа на этот вопрос и надеюсь, что он есть.
Я использую 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
grep run-parts /etc/crontabчто просто найдите инструкции о том, когда run-parts вызывается для каждого из этих каталогов.
Со страницы руководства:
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. Благодарю.
Для CentOS 6 вам нужно выполнить grep / etc / anacrontab, и ответ будет разным, если сервер / ноутбук / 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
Таким образом, между часами 3:00 и 22:00 (после перезагрузки и после того, как компьютер работал в течение 5 минут ^^), запустите /etc/cron.daily. Если перезагрузки нет, задание должно выполняться в 3:05++.
** 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
Для систем SuSE (в частности, SLES 11.1 и openSuSE 10.3) ежедневное время выполнения сценариев /etc/cron.daily контролируется значением переменной DAILY_TIME, установленной в файле / etc / sysconfig / cron .
Если переменная DAILY_TIME не установлена, по умолчанию используется значение: (время последней загрузки + 15 минут).
В Ubuntu вы найдете файл / etc / crontab, из которого он настроен. Я думаю, что это похоже на RH и Centos.
CentOS6.x / RedHat6.x по умолчанию устанавливает пакет cronie-anacron. Вы должны:
ням установить cronie-noanacron
ням стереть корни-анакрон
Теперь у вас есть /etc/cron.d/dailyjobs для настройки наилучшего расписания для ваших ежедневных, еженедельных и ежемесячных заданий.
Я использую 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
С /etc/anacrontabмоей системы Ubuntu 9.10:
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
Обновление OpenSuse 42.x:
/ etc / crontab показывает файл / usr / lib / cron / run-crons, который должен запускаться каждые 15 минут.
В свою очередь / usr / lib / cron / run-crons (содержит строки кода may), которая ищет переменную DAILY_TIME в / etc / sysconfig / cron
Файл показывает;
# At which time cron.daily should start. Default is 15 minutes after booting
# the system. Example setting would be "14:00".
# Due to the fact that cron script runs only every 15 minutes,
# it will only run on xx:00, xx:15, xx:30, xx:45, not at the accurate time
# you set.
DAILY_TIME=""
Установите нужное время и перезапустите cron с помощью;
systemctl restart cron.service