Results 1 to 4 of 4

Thread: Cron does not run a program

  1. #1
    Join Date
    Dec 2012
    Beans
    1

    Question Cron does not run a program

    I tried to use cron to periodically test the internet connection with a bash script. The cron job self works, the script is called.
    However, in the script I want to open Google Chrome using the command
    chromium-browser --args http://www.google.com

    it works perfectly when the script is called directly through the terminal.
    The command however does not work when the script is called from cron. The logging works perfectly the right way.

    Anyone knows what to do here?

    Here is the data:
    crontab -e:
    * * * * * /home/user/checkinet.sh

    checkinet.sh:
    url="www.google.com";
    if ping -c 1 $url
    then
    echo "Internet is up!" >> /tmp/inetcheck.log
    chromium-browser --args http://www.google.com
    else
    echo "Intenet is down!" >> /tmp/inetcheck.log
    fi

  2. #2
    Join Date
    Aug 2011
    Beans
    322
    Distro
    Xubuntu 13.04 Raring Ringtail

    Re: Cron does not run a program

    Sounds suspiciously like your problem is the environment. Cron uses a clean environment, not the one you normally use. See http://ubuntuforums.org/showthread.php?t=2084935 message #4 for more info and possible solution approach.

  3. #3
    Join Date
    Apr 2012
    Beans
    5,465

    Re: Cron does not run a program

    in particular what DISPLAY do you expect it to open the browser window on and does cron have xauth on that display?

  4. #4
    Join Date
    Jul 2012
    Location
    Illinois, USA
    Beans
    499
    Distro
    Ubuntu 12.04 Precise Pangolin

    Lightbulb Re: Cron does not run a program

    Also, the way you have the cron scheduled, you might want to check for already running instances of Chrome. Otherwise, you'll end up with a new window opening up every 60 seconds when the cron runs again and finds that the Internet is up.

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
  •