LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   cron errors: failed with exit status 1 (https://www.linuxquestions.org/questions/linux-newbie-8/cron-errors-failed-with-exit-status-1-a-918301/)

mike11 12-12-2011 04:57 AM

cron errors: failed with exit status 1
 
Hello,

I've recently installed the latest debian stable, and now my cron file isn't working (it was working fine before the installation). It contains lines which invoke zenity to produce popup messages, for example:
Code:

00 12 * * * zenity --info --text "hello" --display=:0.0
/var/log/syslog shows errors of the form:
Code:

Dec 12 19:47:01 mike /USR/SBIN/CRON[13583]: (CRON) error (grandchild #13552 failed with exit status 1)
zenity works fine from the CLI.

Any ideas?

TIA,
Mike

colucix 12-12-2011 05:55 AM

Just my :twocents:

1. Are you sure the cron message is related to your job? I see no direct relationship between the posted crontab and the log. Be sure by checking the timestamp of the log and your actual crontab.

2. Is display :0.0 running/assigned at the time of the job execution?

3. I'd check also the scripts in /etc/cron.d, /etc/cron.hourly, /etc/cron.daily etc. to see if one of them is faulty due to the recent upgrade. For example, someone reported that /etc/cron.d/update-motd no longer works, since its functionality has been integrated into pam_motd module.

mike11 12-12-2011 06:57 PM

Thanks for replying.

It's definitely my cron jobs which invoke zenity, as /var/log/syslog shows:
Code:

Dec 13 09:55:01 mike /USR/SBIN/CRON[2837]: (mike) CMD (zenity --info --text "a" --display=:0.0)
Dec 13 09:55:01 mike /USR/SBIN/CRON[2836]: (CRON) error (grandchild #2837 failed with exit status 1)
Dec 13 09:55:01 mike /USR/SBIN/CRON[2836]: (mike) END (zenity --info --text "a" --display=:0.0)


Dark_Helmet 12-12-2011 09:33 PM

In the past, 99% of my cron job problems were caused because I always forgot to include full paths to commands in the cron specification.

Your cron job references "zenity" without a path. The command won't be found unless you've taken additional steps in your cron job file to define PATH.

If memory serves, cron executes its jobs in non-interactive shells. In non-interactive shells, not all the "normal" startup files are read. Among those omitted startup files are usually the ones where people define/modify PATH.

Unless you are 100%, absolutely positive that the PATH environment variable is not the issue, then just add the full path to zenity for giggles. On my system, it's located at:

/usr/bin/zenity

mike11 12-12-2011 09:43 PM

Thanks for replying.

The problem was due to zenity being unable to access the xserver, which was never an issue before the recent debian stable version.

Adding this line to .bashrc solved the problem:
Code:

xhost local:mike
and the following line works fine in crontab, that is, a pop-up appears:
Code:

00 12 * * * zenity --info --text "some message"  --display=:0.0


All times are GMT -5. The time now is 11:22 AM.