9

I have added to the PYTHONPATH on my server's .bash_profile file. However it appears that cron isn't reading from it because I am getting import errors. If I run the exact command cron calls on the command line it works, but if I send the error output of cron to a separate file, its failing on the imports.

how can I structure it so that cron is aware of my appended PYTHONPATH

10

cron doesn't read shell startup files. You need to explicitly set the environment you need in the crontab or in the script that is being run. You can place variable assignment statements directly in the crontab:

PYTHONPATH=/dir1:/dir2

Each directory you need will have to be listed, because you can't append to it since the previous value isn't available.

2

Include at the begining of the script.

. [directorypath].bash_profile

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.