Cómo programar tareas en Linux usando el `en el' comando

por Sukrit Dhandhania en 4 de mayo de 2009

Linux

Los trabajos del Scheduling son una parte esencial de administrar los servidores de Linux. Hechamos una ojeada cómo programar trabajos en usar de la máquina de Linux cron comando anterior. Aquí está un alternativa a cron - en. La diferencia primaria entre los dos es que cuando usted programar una tarea usando el cron él ejecútese en varias ocasiones sin la necesidad del cambiar la hora. Con en, por otra parte, el programar de una tarea está solamente para una sola ejecución. Ambos comandos tienen su uso, y sugeriría que usted consiga una buena comprensión de ellos ambas.

Miremos cómo programar una tarea de ejecutar solamente una vez usar en comando. Primero cerciórese de que en el demonio está funcionando con un comando como esto:

# picosegundo - ef | grep atd
raíz 8231 ¿1 0 18:10? 00:00: 00 /usr/sbin/atd

Si usted no ve atd comienzo corriente él con este comando:

comienzo de # /etc/init.d/atd

Una vez que hayan comenzado al demonio con éxito usted puede programar en tarea usando las dos opciones - f, para el archivo que se ejecutará, y - v, por el tiempo en el cual debe ser ejecutado. Tan si usted desea ejecutar el shell script shellscript.sh en 6:30 P.M. usted funcionaría el comando siguiente:

# en - f shellscript.sh - v 18:30

Recuerde eso con en ordene la escritura shellscript.sh se ejecutará en 6:30 P.M. y entonces el programar desaparecerá. Tan si esto no es lo que usted desea, usted es mejor de usar cron.

en el comando es bastante listo en que puede tomar algunas órdenes en inglés si usted tiene gusto. Por ejemplo, usted puede programar trabajos usando el sintaxis siguiente también:

# en - f shellscript.sh 10pm mañana

# en - f shellscript.sh 2:50 martes

# en - f shellscript.sh 6:00 el 11 de julio

# en - f shellscript.sh 2:00 la semana próxima

Postes relacionados:
  • Aumente su Linux/productividad del Unix: Cómo utilizar el crontab
  • Tablero de instrumentos Widget: Horario de MLB
  • Cómo parar su Mac de despertar cuando debe dormir
  • Cómo ahorrar la salida de un comando de Linux a un archivo
  • How to post to Twitter from the Linux command line
  • Get Simple Help tutorials just like this one in your email inbox every day - for free! Just enter your email address below:

    You can always opt out of this email subscription at any time.

    { 2 comments… read them below or add one }

    1 MikeT 05.04.09 at 5:26 am

    If you don’t see atd running start it with this command:

    # /etc/init.d/atd start

    More correctly, if it isn’t running, it probably is not configured to startup when the system is restarted. Which may also keep the above command from working as expected. To correct this, use:

    # chkconfig atd --level 234 on
    # service atd start

    and check again to make sure it is running, if it is, continue with the instructions (which are very good BTW).

    2 MikeT 05.04.09 at 5:32 am

    I have another followup for you on use of the at command.

    I’ve run into situations where I’ve needed a command run every hour BUT I needed the command to run ONLY if the previous run has completed. It might not be hung but it might be very very busy. I don’t mind skipping an hour’s execution if the process is still busy.

    When this situation arises, I don’t use cron, I use ‘at’ and the last thing I put in my script is the at command itself to resubmit the job for execution.

    Now, even if the job takes three hours, at the top of the following hour, the at command will launch the job as expected without cron jobs bumping into each other.

    Yes, there’s ways to put the logic into a script for cron to deal with it but that can also be difficult to maintain and not as obvious (to some) as this approach.

    Leave a Comment

    You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>