Quando o 'cron.daily' é executado?

181

Quando as entradas em cron.daily (e .weekly e .hourly ) são executadas e são configuráveis?

Eu não encontrei uma resposta definitiva para isso, e espero que haja uma.

Estou executando o RHEL5 e o CentOS 4, mas para outras distros / plataformas seria ótimo também.

    
por warren 26.04.2010 / 15:31

10 respostas

138

Para as distribuições mencionadas:

No CentOS 5.4 (deve ser o mesmo para o 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

Então o cron.daily é executado às 04:02.

Same on CentOS 4.8

    
por 26.04.2010 / 16:23
64

Da página do manual:

 Cron also searches for /etc/anacrontab

/etc/anacrontab no meu sistema (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

Veja também man anacrontab

    
por 26.04.2010 / 15:35
38

Para o CentOS 6, você precisa do grep / etc / anacrontab e a resposta varia se o servidor / laptop / dekstop / etc estiver desativado ou não.

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

Assim, entre as 3 e as 10 da noite (após a reinicialização e depois de a máquina funcionar por 5 minutos ^^), execute /etc/cron.daily. Se não houver reinicialização, o trabalho deverá ser executado às 03h05.

** 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

Referência: link

    
por 29.10.2012 / 21:20
13

Para sistemas SuSE (especificamente SLES 11.1 e openSuSE 10.3), o tempo de execução diário dos scripts /etc/cron.daily é controlado pelo valor da variável DAILY_TIME definida no / arquivo etc / sysconfig / cron .

Se a variável DAILY_TIME não estiver definida, o padrão é: (tempo da última inicialização + 15 minutos).

    
por 16.08.2012 / 03:18
9

No Ubuntu, você encontrará um arquivo / etc / crontab, onde está configurado. Eu acho que é algo semelhante em RH e Centos.

    
por 26.04.2010 / 15:33
4

O CentOS6.x / RedHat6.x instala por padrão o pacote cronie-anacron. Você precisa:

yum install cronie-noanacron

yum erase cronie-anacron

Agora você tem o /etc/cron.d/dailyjobs para configurar o melhor horário para seus trabalhos diários, semanais e mensais.

    
por 29.08.2012 / 19:50
4

Eu uso o Slackware (14.0) e não tenho /etc/crontab . Além disso, anacron não faz parte da distribuição.

A solução no meu sistema foi tão simples quanto executar crontab -l como 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
    
por 12.03.2014 / 21:50
3

De /etc/anacrontab no meu sistema 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
    
por 26.04.2010 / 15:54
2

Não existe tal facilidade no que diz respeito ao Solaris. Basta usar entradas regulares de crontab para tarefas diárias.

    
por 26.04.2010 / 15:52
1

Atualização do OpenSuse 42.x:

/ etc / crontab mostra um arquivo / usr / lib / cron / run-crons que deve ser executado a cada 15 minutos.

/ usr / lib / cron / run-crons por sua vez (possui linhas de código) que está procurando por uma variável chamada DAILY_TIME em / etc / sysconfig / cron

O arquivo mostra:

# 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=""

Defina o tempo que você precisa e reinicie o cron via;

systemctl restart cron.service
    
por 20.08.2018 / 15:05