How to set up environment for Python in cron?
Posted on 2010-11-09
I have a Python script that runs fine standalone. When I add it to the cron on a Solaris, it fails. From the output log, the problem is it cannot find the PATH and LID_LIBRARY_PATH of the executable embedded in the Python. My question is how to set this up? Should this be done in the Python or in the cron? I have tried various ways without success. Here are two examples:
02 * * * * /home/<user>/test.py input1 > /tmp/test.log 2>&1
02 * * * * SHELL=/usr/bin/bash; export SHELL; . $HOME/.profile_user; /home/<user>/test.py input1 > /tmp/test.log 2>&1
Basically the Python runs with one input parameter. In the Python script, it calls a 3rd party executable. I see two env variable scripts I need to run - one is the .profile_user and another one is the app specific env.