Where can I set environment variables that crontab will use?

后端 未结 17 1945
说谎
说谎 2020-11-22 05:47

I have a crontab running every hour. The user running it has environment variabless in the .bash_profile that work when the user runs the job from the terminal,

17条回答
  •  我在风中等你
    2020-11-22 06:25

    Unfortunately, crontabs have a very limited environment variables scope, thus you need to export them every time the corntab runs.

    An easy approach would be the following example, suppose you've your env vars in a file called env, then:

    * * * * * . ./env && /path/to_your/command

    this part . ./env will export them and then they're used within the same scope of your command

提交回复
热议问题