LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (http://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   Any sane way to renice a process by path, every time it is started? (http://www.linuxquestions.org/questions/linux-desktop-74/any-sane-way-to-renice-a-process-by-path-every-time-it-is-started-4175463540/)

Gullible Jones 05-26-2013 09:39 PM

Any sane way to renice a process by path, every time it is started?
 
Say you have a situation where you want a given program to always run at a certain niceness, regardless of who invokes it or how. What's a sensible way to do this? verynice would probably work, but seems like enormous overkill; and using a cron job would be... well, not very sensible.

What I'd like to do is write a script that watches continuously for the start of some process, renices it *once* as soon as it is launched, and then leaves it alone. What methods are available for checking on processes this way?

druuna 05-27-2013 03:33 AM

Maybe you could use a wrapper script to accomplish this?

If the given program always needs its niceness to be adjusted you could try the following:

- Rename the given program: mv given_program given_program.org
- Create a wrapper script named given_program with the following content:
Code:

#!/bin/bash

nice -n 19 given_program.org "$@"

Make sure that:
- The wrapper script is in the same location as the original,
- The wrapper script has the same owner/permissions as the original program.

BTW: The "$@" part makes sure that all the (possible) options/parameters are given to the original program.


All times are GMT -5. The time now is 06:07 AM.