Where can I set environment variables that crontab will use?

后端 未结 17 1774
说谎
说谎 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:29

    I got one more solution for this problem:

    0 5 * * * . $HOME/.profile; /path/to/command/to/run
    

    In this case it will pick all the environment variable defined in your $HOME/.profile file.

    Of course $HOME is also not set, you have to replace it with the full path of your $HOME.

提交回复
热议问题