I use crontab to do some tasks in background. I have a Python script, I just put it into crontab not long ago. But I got a mail from crontab, the script raised ImportError.
It imports PyQuery, which I just knew and started to use it for my own good. I installed it into my home directory not system-wide. Of course, environment variable PYTHONPATH is correct when I am running that script. But it’s not the environment that cron can have.
I didn’t know how to resolve until I read /etc/crontab. It has these lines before the table of tasks:
# Global variables
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
So, I added the following to my crontab:
PYTHONPATH="/home/livibetter/lib/python2.5:/usr/local/lib64/python2.6"
Which is from my .bash_profile.
That resolved.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.