【发布时间】:2021-03-04 11:24:40
【问题描述】:
我已经在 /etc/profile 和 ~/profile 中设置了我的环境变量。当我运行 echo $EVNAME 时,它会正确返回,但作为 Cron 作业运行会返回 None。
我在 Raspberry Pi 4 上运行它并使用 Python3 编写脚本。
对这个有帮助吗?
【问题讨论】:
标签: python cron environment-variables
我已经在 /etc/profile 和 ~/profile 中设置了我的环境变量。当我运行 echo $EVNAME 时,它会正确返回,但作为 Cron 作业运行会返回 None。
我在 Raspberry Pi 4 上运行它并使用 Python3 编写脚本。
对这个有帮助吗?
【问题讨论】:
标签: python cron environment-variables
配置文件的正确路径是/etc/profile。如果您打算将其设置为特定用户,则为 ~/.bashrc。
【讨论】:
echo $MY_VAR的环境吗?您是否运行了source 命令来“重新加载环境变量?cronjob 是直接调用 python 脚本还是通过 shell 脚本?@Benzine