Les travaux de Scheduling est une partie essentielle d'administrer des serveurs de Linux. Nous avons jeté un coup d'oeil à la façon programmer les travaux sur employer de machine de Linux cron commande plus tôt. Voici une alternative à cron - à. La différence primaire entre les deux est que quand vous programmez un charger en utilisant le cron il exécutez à plusieurs reprises sans besoin de remise à plus tard. Avec à, d'une part, l'établissement du programme d'un charger est seulement pour une exécution simple. Tous les deux commandes ont leur utilisation, et je proposerais que vous obteniez un bon arrangement de eux tous les deux.
Regardons comment programmer un charger pour exécuter employer seulement une fois à commande. Assurez-vous d'abord que au démon court en utilisant une commande comme ceci :
# picoseconde - E-F | grep ATD
racine 8231 1 0 18:10 ? 00:00 : 00 /usr/sbin/atd
Si vous ne voyez pas ATD début courant il avec cette commande :
début de # /etc/init.d/atd
Une fois que le démon a été commencé avec succès vous pouvez programmer à chargez en utilisant les deux options - f, pour le dossier à exécuter, et - v, pendant le temps à l'où il devrait être exécuté. Ainsi si vous voulez exécuter le manuscrit de coquille shellscript.sh chez 6:30 P.M. vous courriez la commande suivante :
# - f shellscript.sh - à v 18:30
Rappelez-vous cela avec à commandez le manuscrit shellscript.sh s'exécutera chez 6:30 P.M. et alors l'établissement du programme disparaîtra. Ainsi si n'est pas ce ce que vous désirez, vous êtes meilleur outre d'employer cron.
à la commande est assez intelligente parce qu'elle puisse prendre quelques ordres en anglais si vous aimez. Par exemple, vous pouvez programmer les travaux en utilisant la syntaxe suivante aussi bien :
# - à f shellscript.sh 10pm demain
# - à f shellscript.sh 2:50 mardi
# - à f shellscript.sh 6:00 le 11 juillet
# - à f shellscript.sh 2:00 la semaine prochaine

























{ 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