Похожие чаты

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 ответов

7 просмотров

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

Ehsan- Автор вопроса
Agent Q | You PM me, You Pay
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 | You PM me, You Pay
Try logging this

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

Ehsan- Автор вопроса
Ehsan- Автор вопроса
Agent Q | You PM me, You Pay
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 | You PM me, You Pay
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

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

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

А еще в перле можно уже @arr1 + @arr2?
Sergei Zhmylove
53
я не магистр хаскеля, но разве не может лейзи тип конвертнуться в не-лейзи запросив вычисление содержимого прям при инициализации?
deadgnom32 λ madao
100
Подскажите, где смотреть результат выполнения программы? Код: ;.686 ;Система команд процессора 686 ;.MODEL FLAT,stdcall ;Модель памяти плоская, станда...
Егор Анелькин
5
I arrived here after a Chico Crypto show highlighted the project & the Team - the fact that the Team had a long history of successfully working with household names gave me e...
Banter is Bullish
1
Привет всем. появился вопрос. Разрабатываю сайт, в данный момент он запущен. Хостинг beget. Добавляю на сайт яндекс метрику с помощью полей client-settings (взято отсюда http...
Andrew
2
;.686 ;Система команд процессора 686 ;.MODEL FLAT,stdcall ;Модель памяти плоская, стандартный ;вызов процедуры ;option casemap:no...
Егор Анелькин
1
Почему у макбука экран не сенсорный?
✨ Anatolii Cherednichenko
28
почому оно не работает?
Vi Chapmann Chapmann
19
It's unfortunate that the "Then why are you here" or "lol you must've bought high" mantras always come up. I already tried bringing up this subject in the price channel but si...
Leroy Gerrits
4
Так а кто может спарсить всех участников чата? Идишники
Magic
18
Карта сайта