Python script not working from cron

I have a python script "start.py" that works fine from the command line. It has only one statement (type "hello"). EDIT: start.py also contains a working interpreter directive in the first line.

As soon as I run the script from the cron job, every time it fires, a message appears in syslog:

Jun 7 02:57:01 mit CRON[23275]: Module is unknown 

I have already tried adding PATH and PYTHONPATH information to the cron file:

 $ cat /etc/cron.d/my_cron PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PYTHONPATH=/usr/lib/python2.6:/usr/lib/python2.6/plat-linux2:/usr/lib/python2.6/lib-tk:/usr/lib/python2.6/lib-old:/usr/lib/python2.6/lib-dynload:/usr/lib/python2.6/dist-packages:/usr/lib/pymodules/python2.6:/usr/lib/pymodules/python2.6/gtk-2.0:/usr/local/lib/python2.6/dist-packages * * * * * mit /home/mit/dev/start.py 

I found several answers and solutions that seem to be the same, but nothing helped me. What am I missing?

+4
source share
2 answers

A recent PAM update has broken cron. Try restarting your computer (or restart cron using sudo /etc/init.d/cron restart )

+3
source

You forgot to add python in front of it.

 * * * * * mit /usr/bin/python /home/mit/dev/start.py 
0
source

All Articles