Suse/OpenSuSE - [решено] Время срабатывания cron

Ответить
Аватара пользователя
hasherfrog

Suse/OpenSuSE - [решено] Время срабатывания cron

Сообщение hasherfrog »

Ситуация такая. Есть сервак на SUSE LINUX 10.0 (X86-64) Linux 2.6.13-15.8-smp #1 SMP Tue Feb 7 11:07:24 UTC 2006 x86_64 x86_64 x86_64 GNU/Linux. На нём периодически запускается updatedb, раз в день. За это отвечает crond, в crontab написано:



Код:

Код: Выделить всё

cat /etc/crontab
SHELL=/bin/sh
PATH=/usr/bin:/usr/sbin:/sbin:/bin:/usr/lib/news/bin
MAILTO=root
#
# check scripts in cron.hourly, cron.daily, cron.weekly, and cron.monthly
#
-*/15 * * * *   root  test -x /usr/lib/cron/run-crons && /usr/lib/cron/run-crons >/dev/null 2>&1

,

а вызов updatedb идёт из одного из скриптов cron.daily[/i]



Срабатывают скрипты из cron.daily строго в определённое время дня, 11:30. Как мне изменить это время?
Аватара пользователя
[mzd]

Re: Suse/OpenSuSE - [решено] Время срабатывания cron

Сообщение [mzd] »

hasherfrog, в файле /etc/crontab:


Цитата:



22.1.2 The cron Package



If you want to run commands regularly and automatically in the background at predefined times, cron is the traditional tool to use. cron is driven by specially formatted time tables. Some of of them come with the system and users can write their own tables if needed.



The cron tables are located in /var/spool/cron/tabs. /etc/crontab serves as a systemwide cron table. Enter the username to run the command directly after the time table and before the command. In Example 22-1, root is entered. Package-specific tables, located in /etc/cron.d, have the same format. See the cron man page (man cron).



Example 22-1 Entry in /etc/crontab



1-59/5 * * * * root test -x /usr/sbin/atrun && /usr/sbin/atrun



You cannot edit /etc/crontab by calling the command crontab -e. This file must be loaded directly into an editor, modified, then saved.



A number of packages install shell scripts to the directories /etc/cron.hourly, /etc/cron.daily, /etc/cron.weekly, and /etc/cron.monthly, whose execution is controlled by /usr/lib/cron/run-crons. /usr/lib/cron/run-crons is run every 15 minutes from the main table (/etc/crontab). This guarantees that processes that may have been neglected can be run at the proper time.



To run the hourly, daily, or other periodic maintenance scipts at custom times, remove the time stamp files regulary using /etc/crontab entries (see Example 22-2, which removes the hourly one before every full hour, the daily one once a day at 2:14 a.m., etc.).



Example 22-2 /etc/crontab: Remove Time Stamp Files



59 * * * * root rm -f /var/spool/cron/lastrun/cron.hourly

14 2 * * * root rm -f /var/spool/cron/lastrun/cron.daily

29 2 * * 6 root rm -f /var/spool/cron/lastrun/cron.weekly

44 2 1 * * root rm -f /var/spool/cron/lastrun/cron.monthly



The daily system maintenance jobs have been distributed to various scripts for reasons of clarity. They are contained in the package aaa_base. /etc/cron.daily contains, for example, the components suse.de-backup-rpmdb, suse.de-clean-tmp, or suse.de-cron-local.



Взято
тут
Аватара пользователя
hasherfrog

Re: Suse/OpenSuSE - [решено] Время срабатывания cron

Сообщение hasherfrog »

Вроде бы понял, сейчас оттестирую, отпишусь...



updated

Как-то всё через одно место сделано....



В общем, скрипт /usr/lib/cron/run-crons использует время изменения системного статуса файла для определения, не пора ли сделать работу. Не время создания файла, не время его последней модификации, а именно изменения статуса!! Это делает невозможным использование команды touch для корректировки (управления временем) запуска "ежедневного задания" (потому что touch, входящий в дистрибутив, не поддерживает изменение изменения статуса).



Буду думать. Проблема в том, что меня не устраивает вариант решения, приведённый выше (удалять каждый день по расписанию, чтобы потом опять файл создался и не использовался целый день).



updated

Хотя, с другой стороны, пофиг, пусть так будет, некогда разбираться.

*решено*
Аватара пользователя
andrew-spb

Re: Suse/OpenSuSE - [решено] Время срабатывания cron

Сообщение andrew-spb »

В файле /etc/sysconfig/cron нужно установить перемнную DAILY_TIME поумолчанию она не установлена и скрипт выполняется через 15 минут после запуска системы.

PS (возможно у Вас она установлена на 11:30)
Ответить

Вернуться в «Общий по Linux»