5

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.

  • Which major RHEL release, 6 or 7? – HBruijn Oct 18 '16 at 2:27
  • Are you really that CPU constrained at this point? You should be careful of this type of design because there may be unintended consequences. – ewwhite Oct 18 '16 at 3:00
  • What @HBruijn said. – Michael Hampton Oct 18 '16 at 3:07
  • yes, I'm aware of the dangers. In this case I have a daemon (radium) that collects data over the network and every hour compresses the last hours data. The compress jobs were hogging the cpu and I was loosing data because radium is not reading it fast enough. I am keeping an eye on it to make sure the compress jobs finish before the next run ;) – Russell Fulton Oct 18 '16 at 22:29
8

You just launch it with nice.

E.g.:

nice -n 18 /path/to/mydaemon

| improve this answer | |
  • Ah Thanks! that works fine. I was mislead by man page that states: -n, --adjustment=N add integer N to the niceness (default 10) where as it seems not to reflect reality ??? This whole thing with "niceness" and "priority" is confusing – Russell Fulton Oct 18 '16 at 22:20
2

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

nice -n18 ionice -c3 /path/to/mydaemon
| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.