1

I'm trying to get a python file to run every 2 mins, I'm using the following cron command but the script never runs. Would anyone know what the possible errors could be related to starting a python file using cron..?

*/2 * * * * /git/project/tags/python scrape.py
  • 2
    The command should use absolute paths. /git is probably in your home directory, not in the file system root. Moreover, for python you will probably want the system wide binary /usr/bin/python. – Jos Jul 2 '14 at 13:31
  • thanks I got it working using /usr/bin/python /home/user1/git/project/tags/scrape.py – david Jul 2 '14 at 14:41
4

I would add also the full path to the script file scrape.py even if it is located into the same directory as your python executable.

Also, I would happen redirection to the command line to get possible error and output into a file, at least for debugging purpose :

*/2 * * * *   /git/project/tags/python /full/path/to/scrape.py >>/tmp/scrape.out 2>>&1

This way, the standard output and error output will be appended to the same file.

Also note that the output of any cron activity will be sent by mail to the user owning the crontab in question.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.