Reading the documentation at this link I can easily add a compile-time known variable within a systemd service, for example


So that


Is "content"

But what about the case I would need such VARIABLE be given by a program, i.e. /home/user/myprogram? Is there any way to make that Environment tag to fetch that program standard output?

  • 1
    Not sure, so I'm just dropping a comment here. It seems not to be possible; some alternatives I see are 1) setting variables in ExecStart (example); 2) use systemd.environment-generator - it won't set per-unit variables, but note that the environment of each unit is available via D-Bus anyway. – fra-san Feb 24 at 14:53
  • 1
    I'm not sure I understand what are you asking for. But could your program generate an environment file, which you can then load via EnvironmentFile=? – marbu Mar 1 at 18:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.