The Computer Oracle

cron can't read PYTHONPATH environment variables?

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------

Take control of your privacy with Proton's trusted, Swiss-based, secure services.
Choose what you need and safeguard your digital life:
Mail: https://go.getproton.me/SH1CU
VPN: https://go.getproton.me/SH1DI
Password Manager: https://go.getproton.me/SH1DJ
Drive: https://go.getproton.me/SH1CT


Music by Eric Matyas
https://www.soundimage.org
Track title: Hypnotic Puzzle2

--

Chapters
00:00 Cron Can'T Read Pythonpath Environment Variables?
00:25 Accepted Answer Score 10
00:48 Answer 2 Score 2
00:55 Thank you

--

Full question
https://superuser.com/questions/239975/c...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #environmentvariables #cron #crontab

#avk47



ACCEPTED ANSWER

Score 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.




ANSWER 2

Score 2


Include at the begining of the script.

. [directorypath].bash_profile