Page 1 sur 1

[Cron] exit status 1 from user XXX

Publié : ven. 28 mai 2010, 09:52
par Florian Goo
Salut les Acheux !

Je dois prendre des médocs à heure fixe. J'ai donc configuré Cron pour recevoir des notifications visuelles (avec la commande notify-send de Gnome) :

Code : Tout sélectionner

florian@flobox:~$ sudo cat /var/spool/cron/florian 
Password: 
0 21 * * * notify-send -t 0 "Médicaments" # JOB_ID_1
0 9 * * * notify-send -t 0 "Médicaments" # JOB_ID_2
0 12 * * * notify-send -t 0 "Médicaments" # JOB_ID_3
Cependant, aucune notification n'apparait.

Crond est pourtant bien démarré (il est dans la liste des démons dans mon rc.conf) :

Code : Tout sélectionner

florian@flobox:~$ ps -A | grep cron
 2063 ?        00:00:00 crond
Selon les logs, il y a effectivement une erreur renvoyée à l'exécution de ma commande :

Code : Tout sélectionner

florian@flobox:~$ sudo tail /var/log/crond.log
Password: 
May 22 15:34:47 flobox crond[2063]: /usr/sbin/crond 4.4 dillon's cron daemon, started with loglevel info
May 22 15:35:01 flobox crond[2063]: FILE /var/spool/cron/root USER root PID 2479 job sys-hourly
May 22 17:35:01 flobox crond[2063]: FILE /var/spool/cron/root USER root PID 7436 job sys-hourly
May 22 19:35:01 flobox crond[2063]: FILE /var/spool/cron/root USER root PID 11989 job sys-hourly
May 22 21:00:01 flobox crond[2063]: FILE /var/spool/cron/florian USER florian PID 15132 notify-send -t 0 "Médicaments" # JOB_ID_1
May 22 21:00:01 flobox crond[2063]: exit status 1 from user florian notify-send -t 0 "Médicaments" # JOB_ID_1
May 22 21:00:01 flobox crond[15134]: mailing cron output for user florian notify-send -t 0 "Médicaments" # JOB_ID_1
May 22 21:00:01 flobox crond[15134]: unable to exec /usr/sbin/sendmail: cron output for user florian notify-send -t 0 "Médicaments" # JOB_ID_1 to /dev/null
May 22 21:35:01 flobox crond[2063]: FILE /var/spool/cron/root USER root PID 16468 job sys-hourly
Étrangement, si je redémarre cron manuellement…:

Code : Tout sélectionner

florian@flobox:~$ sudo /etc/rc.d/crond restart
Password: 
:: Stopping Cron Daemon                                                  [DONE] 
:: Starting Cron Daemon                                                  [DONE]
… tout rentre dans l'ordre, mes commandes sont bien exécutées et les notifications apparaissent :

Code : Tout sélectionner

May 22 23:36:26 flobox crond[21150]: /usr/sbin/crond 4.4 dillon's cron daemon, started with loglevel info
May 22 23:37:01 flobox crond[21150]: FILE /var/spool/cron/florian USER florian PID 21182 notify-send -t 0 "test" # JOB_ID_4
Voici la liste des démons de mon rc.conf :

Code : Tout sélectionner

DAEMONS=(syslog-ng !network !netfs crond dbus hal fam @wicd gdm)
En lisant ce topic : http://forums.archlinux.fr/topic6049.html j'ai trouvé une sorte de similitude qui m'a donné un indice sur la nature du problème, mais je ne sais toujours pas le résoudre pour autant…

Que faire ?

Re: [Cron] exit status 1 from user XXX

Publié : ven. 28 mai 2010, 10:11
par oktoberfest
Salut,

je ne connais pas la commande notufy-sen mais je pense que la échoue car elle n'a pas de terminal pour s'exécuter.
Si tu refais un ps -A | grep crond après avoir lancé manuellement ton cron, je suis sur que le ? est remplacé par un tty...

Re: [Cron] exit status 1 from user XXX

Publié : ven. 28 mai 2010, 10:49
par Florian Goo
notify-send permet d'afficher une notification graphique, comme sur cette image : http://ubuntu.online02.com/files/notify.jpg
Si tu refais un ps -A | grep crond après avoir lancé manuellement ton cron, je suis sur que le ? est remplacé par un tty...
Eh non !

Code : Tout sélectionner

florian@flobox:~$ sudo /etc/rc.d/crond restart
Password: 
:: Stopping Cron Daemon                                                  [DONE] 
:: Starting Cron Daemon                                                  [DONE] 
florian@flobox:~$ ps -A | grep crond
 8990 ?        00:00:00 crond

Re: [Cron] exit status 1 from user XXX

Publié : ven. 28 mai 2010, 11:51
par tuxce
Ca doit être une erreur dû à X, DISPLAY ne doit pas être définie, et le restart doit prendre en compte les variables $XAUTHORITY et $DISPLAY qui ne sont définis que quand tu lances une session, essaie avec la ligne suivante:

Code : Tout sélectionner

0 21,9,12 * * * DISPLAY=:0 notify-send -t 0 "Médicaments" # JOB_ID_1

Re: [Cron] exit status 1 from user XXX

Publié : ven. 28 mai 2010, 11:54
par oktoberfest
Une redirection 'notify-send... > /tmp/toto 2>&1' t'indiquera l'erreur suivante :

Code : Tout sélectionner

libnotify-Message: Unable to get session bus: /usr/bin/dbus-launch terminated abnormally with the following error: Autolaunch error: X11 initialization failed.

Re: [Cron] exit status 1 from user XXX

Publié : ven. 28 mai 2010, 11:57
par oktoberfest
tuxce, c'est exactement cela le problème. avec DISPLAY=:0 àa marche nickel.
Trop fort !! :bravo:

Re: [Cron] exit status 1 from user XXX

Publié : sam. 29 mai 2010, 09:24
par Florian Goo
Manifestement, cela ne règle pas le problème chez moi…

Code : Tout sélectionner

florian@flobox:~$ sudo tail /var/log/crond.log
Password: 
May 29 08:30:35 flobox crond[2022]: /usr/sbin/crond 4.4 dillon's cron daemon, started with loglevel info
May 29 08:31:01 flobox crond[2022]: FILE /var/spool/cron/root USER root PID 2342 job sys-hourly
May 29 09:00:01 flobox crond[2022]: FILE /var/spool/cron/florian USER florian PID 3773 DISPLAY=:0 notify-send -t 0 "Médicaments" # JOB_ID_2
May 29 09:00:01 flobox crond[2022]: exit status 1 from user florian DISPLAY=:0 notify-send -t 0 "Médicaments" # JOB_ID_2
May 29 09:00:01 flobox crond[3775]: mailing cron output for user florian DISPLAY=:0 notify-send -t 0 "Médicaments" # JOB_ID_2
May 29 09:00:01 flobox crond[3775]: unable to exec /usr/sbin/sendmail: cron output for user florian DISPLAY=:0 notify-send -t 0 "Médicaments" # JOB_ID_2 to /dev/null
Pourtant, lorsque j'exécute la commande à la main, elle fait bien effet.

Je ne parviens pas non plus à rediriger le flux d'erreur sur la sortie standard. J'ai tenté « ~/cron.err », « /home/florian/cron.err » et « /tmp/cron.err », aucun fichier n'est produit…

Si le problème est une définition de variable d'environnement ou autre, peut-être devrais-je mettre crond à la fin de la liste des démons ?