I want to increase the niceness of an service (decrease the CPU priority) started as an dedicated user or group during the boot process. I'm not able to define the niceness or priority in the /etc/security/limits.conf
or ./limits.d/
directory for the desired user because the entry will not be observed for services. (?)
Example
In particular I've a few small vServers with CentOS 6.6 and want to run a tor relay (The Onion Router) on each.
The tor daemon starts on boot as a service, configured via sudo /sbin/chkconfig
(run level: 2,3,4,5). The user and group for the tor process is _tor
.
Where do I have to change the nice or priority level for every process the user _tor is the owner?
The nice value should be applied on every boot and on manual service start (service tor start
).
Best Answer
The classical approach is to use
nice
and/orionice
within the service start-up script. You probably have something like:and change that to
Alternatively the start-up script often logs the PID of a daemon in
/var/run/pid-of-tor-daemon
or similar and you could userenice
on that PID after the daemon has started.A better approach is with cgroups. That is slightly too long for an answer here, but the Red Hat documentation might be a useful start.