Компьютерный форум OSzone.net  

Компьютерный форум OSzone.net (http://forum.oszone.net/index.php)
-   Общий по Linux (http://forum.oszone.net/forumdisplay.php?f=9)
-   -   [решено] Время срабатывания cron (http://forum.oszone.net/showthread.php?t=111501)

hasherfrog 15-07-2008 13:22 851986

Время срабатывания cron
 
Ситуация такая. Есть сервак на 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

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

[mzd] 15-07-2008 13:37 851997

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 15-07-2008 14:08 852020

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

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

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

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

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

andrew-spb 07-01-2009 21:21 999910

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


Время: 20:06.

Время: 20:06.
© OSzone.net 2001-