cron can't read PYTHONPATH environment variables?

9

1

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

JiminyCricket

Posted 2011-01-31T15:07:34.433

Reputation: 541

Answers

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.

Paused until further notice.

Posted 2011-01-31T15:07:34.433

Reputation: 86 075

2

Include at the begining of the script.

. [directorypath].bash_profile

IamSk

Posted 2011-01-31T15:07:34.433

Reputation: 21