12

Notes: 1. by lower priority I mean that the priority number is lower. 2. Distro is RHE

I want to start a daemon with lower than normal priority (ie. say 18 rather than 20) so it will get cpu first in the case of contention.

nice runs commands at increased priority, renice can raise or lower but works for processes that are already running.

I would rather not have to dig the pid out of the process list and then call renice in the start script if I can avoid it since the program does not conveniently produce a pid file.

Jenny D
  • 28,400
  • 21
  • 80
  • 117

3 Answers3

18

You just launch it with nice.

For example:

nice -n 18 /path/to/mydaemon
dmourati
  • 26,498
9

Additionally, you can use the ionice command to start the process with low io priority:

nice -n18 ionice -c3 /path/to/mydaemon
1

I could be wrong, I thought positive numbers in nice reduce the CPU of an app, and negative make it faster? So to increase the prio / CPU I use negative integers to raise prio in clementine (audio player) with renice:

sudo renice -5 $(pgrep clementine) 
Tomachi
  • 141