Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question
add comment

2 Answers

up vote 6 down vote accepted

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.

share|improve this answer
add comment

Include at the begining of the script.

. [directorypath].bash_profile
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.