Results 1 to 8 of 8

Thread: Crontab Errors

  1. #1
    Join Date
    Oct 2008
    Location
    Down Under
    Beans
    1,568
    Distro
    Ubuntu Budgie 18.04 Bionic Beaver

    Crontab Errors

    I get this error in syslog when I try to run cron -

    Feb 15 18:24:01 9 CRON[2689]: (rodney) CMD (/bin/alarm.sh)
    Feb 15 18:24:01 9 CRON[2688]: (CRON) error (grandchild #2689 failed with exit status 1)
    Feb 15 18:24:01 9 CRON[2688]: (CRON) info (No MTA installed, discarding output)
    The script I am trying to run is called alarm.sh
    The script is

    Code:
    #!/bin/sh
    
    xterm -e ogg123 -z ~/Music/*.ogg
    The crontab is

    Code:
    24 18 15 02 * /bin/alarm.sh

    The script runs from the terminal or 'RUN'

    Any clues ?
    Rodney
    Last edited by Rodney9; February 15th, 2012 at 09:38 AM.

  2. #2
    Join Date
    Mar 2007
    Location
    Portsmouth, UK
    Beans
    Hidden!
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: Crontab Errors

    Try changing your script so that it has absolute paths, then try cron again?

    Code:
    xterm -e ogg123 -z ~/Music/*.ogg
    Code:
    xterm -e ogg123 -z /home/bob/Music/*.ogg

  3. #3
    Join Date
    Oct 2008
    Location
    Down Under
    Beans
    1,568
    Distro
    Ubuntu Budgie 18.04 Bionic Beaver

    Re: Crontab Errors

    Quote Originally Posted by Grenage View Post
    Try changing your script so that it has absolute paths, then try cron again?

    Code:
    xterm -e ogg123 -z ~/Music/*.ogg
    Code:
    xterm -e ogg123 -z /home/bob/Music/*.ogg
    Changed script to

    Code:
    #!/bin/sh
    
    xterm -e ogg123 -z  /home/rodney/Music/*.ogg
    Still works in terminal

    Still get error

    F
    Code:
    eb 15 19:39:01 9 CRON[3222]: (rodney) CMD (/bin/alarm.sh)
    Feb 15 19:39:01 9 CRON[3221]: (CRON) error (grandchild #3222 failed with exit status 1)
    Feb 15 19:39:01 9 CRON[3221]: (CRON) info (No MTA installed, discarding output)
    Rodney

  4. #4
    Join Date
    Mar 2007
    Location
    Portsmouth, UK
    Beans
    Hidden!
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: Crontab Errors

    Code:
    which xterm
    Will give you xterm's path. Try using that, rather than just the name in your script.

  5. #5
    Join Date
    Nov 2007
    Location
    Wisconsin
    Beans
    1,139

    Re: Crontab Errors

    The 'xterm' command opens a window on your display.

    But cron does not have access to your user-level environment variables. It has no idea what display you are using. So it cannot open the window...error.

    You must tell cron which display to open.

    For example, to determine the current display:
    Code:
    $ printenv | grep DISPLAY
    DISPLAY=:0.0
    So alarm.sh would be:
    Code:
    DISPLAY=:0.0 /usr/bin/xterm -e ogg123 -z /home/bob/Music/*.ogg

  6. #6
    Join Date
    Oct 2008
    Location
    Down Under
    Beans
    1,568
    Distro
    Ubuntu Budgie 18.04 Bionic Beaver

    Re: Crontab Errors

    Quote Originally Posted by Cheesehead View Post
    The 'xterm' command opens a window on your display.

    But cron does not have access to your user-level environment variables. It has no idea what display you are using. So it cannot open the window...error.

    You must tell cron which display to open.

    For example, to determine the current display:
    Code:
    $ printenv | grep DISPLAY
    DISPLAY=:0.0
    So alarm.sh would be:
    Code:
    DISPLAY=:0.0 /usr/bin/xterm -e ogg123 -z /home/bob/Music/*.ogg
    Code:
    printenv | grep DISPLAY
    PRIMARY_DEVICE_FOR_DISPLAY=1
    DISPLAY=:
    0

    Thankyou that did trick with

    Code:
    DISPLAY=:0.0 /usr/bin/xterm -e ogg123 -z /home/rodney/Music/*.ogg

    Rodney

  7. #7
    Join Date
    May 2009
    Location
    Rome-ish
    Beans
    26
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Crontab Errors

    Late to the party, but on a slightly unrelated note, assigning a DISPLAY is necessary also for other tasks, in my case audio-recorder, which fired regularly from crontab but didn't really start recording audio chunks until I specified the destination display as Chesehead suggested.
    So thank you Cheesehead

  8. #8
    Join Date
    Jan 2013
    Beans
    3

    Re: Crontab Errors

    Hi I am getting cron logs but only for CMD and INFO not for errors.
    What should i do to get the error logs of cronjobs.
    I purposely created a cronjob in crontab which will run a shell script which does not exist..it should log error in cron logs but it is not doing so..

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •