Похожие чаты

Guys why I can't access env vars inside os from

crontab?
I'm talking about a container environments
Both envs and cron python scripts run on root user

20 ответов

34 просмотра

Depends. How do you access the env var in cli?

Ehsan- Автор вопроса
Agent Q | PM me for Paid Support
Depends. How do you access the env var in cli?

MONGO_CONNECTION = os.getenv('MONGO') And in cli env will return list

Ehsan- Автор вопроса
Ehsan- Автор вопроса
Agent Q | PM me for Paid Support
Try logging this

This returns None when run as a cron and mongo-svc when run manually print(os.getenv('MONGO'))

Ehsan- Автор вопроса
Agent Q | PM me for Paid Support
Maybe the cron isn't taking the env variables

Yes, and I want to know what is the reason and how to solve

Ehsan- Автор вопроса
Agent Q | PM me for Paid Support
What's your cron job command at the moment?

* * * * * /usr/local/bin/python /app/test.py >> /var/log/test.log 2>&1

Ehsan
* * * * * /usr/local/bin/python /app/test.py >> /v...

And if you run something like this manually /usr/local/bin/python /app/test.py >> /var/log/test.log you can see the values of the print(os.getenv('MONGO'))?

Ehsan- Автор вопроса
Ehsan
I did it once manually and you can see the output

Try changing your print to print(f"{os.getenv('MONGO') = }")

Ehsan
Yes, and I want to know what is the reason and how...

https://ypereirareis.github.io/blog/2016/02/29/docker-crontab-environment-variables/

Ehsan
Why it should differ?

Source the env variables into the cron tab as per the article

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта