[systemd-devel] assign variable to some service item

Colin Guthrie gmane at colin.guthr.ie
Wed Oct 5 15:22:40 UTC 2016


As others have said, this is not possible.

It is however possible to configure it via a dropin file.

e.g. if your unit is called foo.service, then just mkdir
/etc/systemd/system/foo.service.d/ and create a file cpu-affinity.conf
inside that folder (any filename will do).

In this file put:

[Service]
CPUAffinity=0-2


Then just reload systemd (systemctl --system reload) and your value
should be available.

It's not an environment file, but it's still an easy file for
administrators to hack on without affecting packaged units in /usr

Note, to make life easier for you, you can simply call "systemctl edit
foo.service" and an editor will open and let you customise it.

HTHs

Col



Vasiliy Tolstov wrote on 29/09/16 09:25:
> I have CPUAffinity inside service file and want to configure it via
> EnvironmentFile, but
> CPUAffinity=$CPUAffinity does not work with message Failed to parse
> CPU affinity '$CPUAffinity'
> Environment file contains CPUAffinity="0-2"
> Does it possible to assign cpu affinity via env variable ?
> Thanks!
> 
> 


-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/


More information about the systemd-devel mailing list