python - Set PYTHONPATH for cron jobs in shared hosting -
i had issues running python script on shared hosting (bluehost), , of other threads able set pythonpath , run script no issues.
now need run script via cron job. cron jobs in shared hosting environment 1 line can call script, can't figure out how set pythonpath before calling script.
example:
python /path/to/my/script.py
i sure issue should common couldn't find answer in other threads.
any idea how set pythonpath cron jobs?
also codebase developed in local environment , server gets copy through git pull. preferred solution not change source code server. it's ok call script cron job calls main script , set variables there, changing main script prefer not happen don't need maintain 2 versions of code 1 local , 1 server.
change cron job run shell script. inside shell script, set pythonpath
, call python program.
change cron job this:
/path/to/my_shell_script.sh
contents of my_shell_script.sh
:
export pythonpath=something python /path/to/py/python/program.py
if don't want have separate shell script, can cram cron entry, although can long:
pythonpath=something python /path/to/py/python/program.py
Comments
Post a Comment