I have installed Python 2.7 through mac ports, and now want to have it used in a cron job. Unfortunatly, each time the cron job gets involved, the standard Python of my machine (an iBook G4 using Tiger) which is 2.3 is involved, making my job fail.
My PATH is (from the set
command)
PATH=/opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin
P
How can I have my cron job be invoked with my PATH
instead of the faulty one ?
Best Answer
The result of the PATH variable is quite different in the cron world. Invoke the script with the full path to the python binary (e.g. /opt/local/bin/python2.7) and you should be good.
This can be examined by running
env
as cronjob and comparing it to the result of runningenv
as yourself in Terminal:user's cron env:
compared to user's env:
Alternatively you may add the PATH to the crontab:
In newer systems (probably ≥10.6):
Change
to