Results 1 to 3 of 3

Thread: Crontab problem

  1. #1
    Join Date
    Jan 2014
    Beans
    2

    Crontab problem

    Hi,
    I have created a cronjob with a command I know to work in the terminal, however, it does not work when executed in cron.
    I have placed this job in the prompt provided by crontab -e.

    Code:


    */1 * * * * /usr/bin/python -c 'import script; script.checkEmail()'

    However, it does not complete. I have other jobs in this file which execute fine.
    Any help would be greatly appreciated.
    Regards.

    (P.S, please note that this command will not work in the terminal if I prefix script (the file) with it's address (/var/www/RA))


  2. #2
    Join Date
    Feb 2009
    Location
    Dallas, TX
    Beans
    7,581
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Crontab problem

    Hi jordan9. Welcome to the forum

    crontab has a very limited environment, so you may need to set some environment variables.

    I'm not familiar with the 'script' module, and its function checkEmail(). If it opens anything from the GUI, you just may need to define DISPLAY. For instance:
    Code:
    */1 * * * * DISPLAY=:0 /usr/bin/python -c 'import script; script.checkEmail()'
    Hope it helps. Let us know how it goes.
    Come here often and have fun.

    Regards.

  3. #3
    Join Date
    Jan 2014
    Beans
    2

    Re: Crontab problem

    Wonderful, thank you!

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
  •