El 10/02/2017 a las 01:30 p.m., Paradix ;) escribió:
Saludos lista

necesito ejecutar una tarea todos los dias de 12 de la noche a las 7 de la mañana y no entiendo que tengo que poner en /etc/crontab ... de hecho no se si me bastara ponerla ahi o si tengo que hacer algo mas.

Esperando ayuda

salu2


necesitas dos scripts entonces.. uno que lance la tarea a las 12 pm y otro qe la pare a las 7 am

no te fajes con /etc/crontab si no lo sabes... solo logueate como el usuario que quieras ejecutar la tarea y escribes en consola:

crontab -e

ese comando te llevara a editar la tabla cron de ese user en cuestion..

Dentro la cosa ya es bastante trivial

              field          allowed values
              -----          --------------
              minute         0-59
              hour           0-23
              day of month   1-31
              month          1-12 (or names, see below)
              day of week    0-7 (0 or 7 is Sun, or use names)

5 campos para la hora y el sexto para la tarea o sea:

1 2 3 4 5 6
0 0 * * * tarea.sh
te ejecutaria la tarea que quieres a las 12 de la noche ... y
0 7 * * * killtarea.sh
ya sabes lo que hace por su nombre

tambien puedes usar @midnight para que sea a medianoche siempre en vez de esos 5 campos...

El caso que dices de editar /etc/crontab  y con solo leer el manual:
man 5 crontab
dice:

EXAMPLE SYSTEM CRON FILE
The following lists the content of a regular system-wide crontab file. Unlinke a user's crontab, this file has the username field, as used by /etc/crontab.

       # /etc/crontab: system-wide crontab
       # Unlike any other crontab you don't have to run the `crontab'
       # command to install the new version when you edit this file
       # and files in /etc/cron.d. These files also have username fields,
       # that none of the other crontabs do.

       SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

       # m h dom mon dow usercommand
       17 * * * *  root  cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
       #

Aqui hay 7 campos pues se agrega el campo del user que va a ejecutar la tarea pero es lo mismo.. dead easy my friend

______________________________________________________________________
Lista de correos del Grupo de Usuarios de Tecnologías Libres de Cuba.
Gutl-l@jovenclub.cu
https://listas.jovenclub.cu/cgi-bin/mailman/listinfo/gutl-l

Responder a