I lavori di Scheduling è una parte essenziale di amministrazione degli assistenti di Linux. Abbiamo dato un'occhiata a come programmare i lavori sul usando della macchina di Linux cron ordine più presto. Qui è un'alternativa a cron - a. La differenza primaria fra i due è che quando programmate un'operazione usando il cron esso esegua ripetutamente senza l'esigenza del rinvio. Con a, d'altra parte, la programmazione di un'operazione è soltanto per una singola esecuzione. Entrambi ordini hanno loro uso e suggerirei che ottenete loro una buona comprensione entrambe.
Guardiamo come programmare un'operazione eseguire soltanto una volta usando a ordine. In primo luogo assicuri che al daemon sta funzionando usando un ordine come questo:
# ps - E-F | grep atd
radice 8231 1 0 18:10? 00:00: 00 /usr/sbin/atd
Se non vedete atd inizio corrente esso con questo ordine:
inizio del # /etc/init.d/atd
Una volta che il daemon è stato iniziato con successo potete programmare a operazione usando le due opzioni - f, per la lima da eseguire e - v, per il tempo a où dovrebbe essere eseguito. Così se desiderate eseguire lo scritto di coperture shellscript.sh a 6:30 PM fareste funzionare il seguente ordine:
# - f shellscript.sh - alla v 18:30
Ricordi di quello con a comandi lo scritto shellscript.sh eseguirà a 6:30 PM ed allora la programmazione sparirà. Così se questo non è che cosa volete, siete migliori fuori del usando cron.
a l'ordine è abbastanza intelligente in quanto può prendere alcuni ordini in inglese se gradite. Per esempio, potete programmare i lavori usando la seguente sintassi pure:
# - alla f shellscript.sh 10pm domani
# - alla f shellscript.sh 2:50 martedì
# - alla f shellscript.sh 6:00 l'11 luglio
# - alla f shellscript.sh 2:00 la settimana prossima

























{ 2 comments… read them below or add one }
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).
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