Changing environment variable of a running process

后端 未结 1 1599
被撕碎了的回忆
被撕碎了的回忆 2020-12-06 05:00

I have a script that exports a environment variable and starts some subscripts.

export LOGLEVEL=\"1\"
/home/myuser/bin/myscript1.sh
/home/myuser/bin/myscript         


        
相关标签:
1条回答
  • 2020-12-06 05:28

    In general, you can only influence a process's environment variables at the time the process starts up. If you need to communicate a change to a running process, the environment isn't the right tool.

    However, this question has some answers that suggest ways to overcome this limitation.

    Edited to add in light of discussion in the question's comments: A fairly good way of communicating occasionally changing setup to a running process is to designate a configuration file where the LOGLEVEL value is set, send a SIGHUP to the process, and have the process reread the configuration file upon receipt of SIGHUP.

    0 讨论(0)
提交回复
热议问题