1 Introduction
Cron est configuré à 3 endroits indépendants :
Les fichiers rangés dans les répertoires /etc/crond.* doivent respecter la grammaire utilisée par run-parts. Cf man cron :
Files must conform to the same naming convention as used by run-parts(8):
they must consist solely of upper- and lower-case letters, digits, underscores, and hyphens.
2 Champs
Cf man 5 crontab :
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)
La syntaxe des fichiers dans /etc/ comprend -en plus de la syntaxe de la crontab de /var/spool/- l'utilisateur sous lequel sera lancé la commande.
3 liens symboliques
On peut lier les CRONTAB rangées ailleurs afin de ne pas éparpiller les informations.
$ ls -l /home/intranet-latex/bin/
-rw-r--r-- 1 root root 245 2009-03-09 17:47 buildNarvalI.cron
-rwxr-xr-x 1 nroche rd 1495 2008-09-21 11:22 buildNarvalI.sh
$ cat /home/intranet-latex/bin/buildNarvalI.cron
0 4 * * 1-6 nroche /home/intranet-latex/bin/buildNarvalI.sh
$ ls -l /etc/cron.d
lrwxrwxrwx 1 root root 26 2009-03-09 17:43 backup-home -> /root/bin/backup-home.cron
lrwxrwxrwx 1 root root 42 2009-03-10 14:29 narvali -> /home/intranet-latex/bin/buildNarvalI.cron
Attention, les crontab doivent cependant appartenir à root.
4 Mail
Si les flux de sortie standard et d'erreur sont redirigés, la CRONTAB n'enverra pas de mail.
0 * * * * /usr/sbin/ntpdate-debian >/dev/null 2>&1
Ici le mail n'est envoyé qu'en cas d'erreur :
# rebuild intranet evry working day
0 4 * * 1-6 nroche \
/home/intranet-latex/bin/buildNarvalI.sh || \
/usr/bin/mail nroche -s "narvali KO" < /home/intranet-latex/log/narvali.log
5 Display
# m h dom mon dow command
50 11 * * 0-7 oclock -display :0 -geometry 1000x800 -fg red -bg green -jewel
red -minut yellow -bd black -transparent
Attention : man 5 crontab
There is no way to split a single command line onto
multiple lines, like the shell's trailing ".
|