1

I am currently using debian 8.2 with systemd.

$ cat /etc/default/openvpn
...
# WARNING: If you're running systemd the rest of the
# options in this file are ignored.
...
# Optional arguments to openvpn's command line
OPTARGS="--nice -20"
#

It seems that this option does not work with systemd. Are there anyway to change the niceness at the start of the openvpn service ?

2
  • Did you take a look at the OpenVPN unit? There could be a settings file somewhere. I'll look into it later.
    – Daniel B
    Dec 15, 2015 at 16:16
  • 1
    You can put the nice -20 also put into the server's config file (without the --).
    – ott--
    Dec 15, 2015 at 16:23

1 Answer 1

1

Under systemd a whole new way of managing system resources exists: cgroups. Every service is assigned to a cgroup, and every cgroup is controlled thru three main controllers, cpu, memory and blkio.

In your case, you may decrease the amount of CPU the openvpn service receives by decreasing its CPUshares. By default, every process receives 1024 CPUshares. If you want to decrease that, say to 800 shares, you create an ad hoc file /etc/systemd/system/openvpn.service which overrides the package-supplied one in /lib/systemd/system, with the following content:

.include /lib/systemd/system/openvpn.service

[Service]
CPUShares=800

The first line reads-in the package-supplied service, the remaining two lines decrease the amount of CPU allocated to the service. Restart the service,

systemctl daemon-reload
systemctl restart openvpn.service

you are done.

You can find an intro to cgroups on PID EINS, and on the ever helpful Arch Linux Wiki.

3
  • Wrong service.
    – JdeBP
    Dec 16, 2015 at 14:42
  • Weird. I wonder how this relates to processes that are not services... lets say process 1 is a service and process 2 is not. Both have the same nice level and both want 100% of the cpu. Under normal circumstances they would both get 50% of the CPU. Now does lowering CPUShares of process 1 result in process 1 getting less than 50% cpu?
    – Motsel
    May 4, 2016 at 21:43
  • 1
    @Daps0l Yes it does, because at this point the two hold different amounts of shares of the CPU. You can also change the CPUShares of a non-service process, to know more you may read the Arch Wiki reference above. May 5, 2016 at 11:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .