Timeline for Resetting service environment variables on stop or restart
Current License: CC BY-SA 4.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 3 at 14:05 | comment | added | Stewart |
In systemd >= 235 UnsetEnvironment= is a thing. See man systemd.exec for details.
|
|
| May 3 at 13:34 | comment | added | Stewart | It would be interesting to understand your use-case a little better. What you're trying to achieve with environments, might be better achieved through other means. | |
| May 3 at 13:30 | comment | added | Stewart |
A service's environment does not persist from one run to the next. When you start a service, the environment is built from scratch, including only the basics from the system manager, and the Environment=/EnvironmentFile= directives. Therefore ExecStopPost= should not have any effect on the next run. Even /etc/profile.d/ has no effect unless you are running your service in a shell.
|
|
| Apr 29 at 12:57 | comment | added | Maikol | EnvironmentFile is called before ExecStart, but I need it called only when the service stops or restarts. | |
| Apr 29 at 12:17 | comment | added | D'Arcy Nader | have you tried to reset the variable in EnvironmentFile directly? calling them two times once as var='' and the second time as var=yourvariable, have no clou if it works, just curious. | |
| Apr 29 at 11:51 | history | edited | Maikol | CC BY-SA 4.0 |
added 15 characters in body
|
| Apr 29 at 11:46 | history | asked | Maikol | CC BY-SA 4.0 |