1

I am trying to add a python script to crontab with following lines:

0 * * * * /pathtoexecutable/file.py
0 0 1 * 1 /pathtoexecutable/file2.py

Files are executable python scripts.

file.py further initiates around 15 subprocesses, which store info in a MySQL database.

file2.py gets, obviously, executed though through crontab as well.

For some reason file.py isn't working via crontab, but if I run it through command line it works.

1
  • Have you activated logging in cron? What is in the log? Commented Jun 6, 2012 at 18:35

1 Answer 1

1

1) Catch the output & errors of yours scripts :.

0 * * * * /pathtoexecutable/file.py &>> /path/some/log.txt
0 0 1 * 1 /pathtoexecutable/file2.py &>> /path/some/log2.txt

2) Be sure that every python file begins with a shebang : #! /usr/bin/env python

3) Be sure too that every python file has a exec mode (chmod +x file.py)

Sign up to request clarification or add additional context in comments.

2 Comments

got nothing in logs.. they are blank you were missing >> in between i guess.. tried through both 2>&1 >> /path/some/log and 2>&1 /path/some/log Got nothing in them the python files begin with a shebang.. I can execute them from commandline without explicitly specifying the interpreter They have 777 permissions
No problem, Zahsas. I got it working now, I don't get it though.. modified command to include interpreter as well.. The scripts contain shebang but still they dont execute directly from cron. They work by specifying interpreter in /usr/local/bin. Thanks for your time. Appreciated!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.