5

I would like to configure my desktop Linux system so that whenever I start running a specific programme (run that processes of this programme) the respective process gets assigned a high priority. How to do this?

I am aware I can do so individually for each instance of running the programme, i.e. for specific processes. But how to configure a default for the programme (i.e. for all future processes)?

4.10.11-200.fc25.x86_64

2

There is a program called "auto nice daemon" which does this. It runs in the background, and when a process matching a particular pattern appears in the process table, it sets its niceness automatically.

You can use this — but, you might be a bit disappointed, because the Linux scheduler has a lot to balance and increasing priority won't necessarily give a magic speed boost. You can even run into situations where it makes things worse, because your high-priority process might "starve" lower-priority processes that your application might actually depend on to move forward.

So, instead, you could look at something like tuned, which has performance profiles for a variety of different workloads. Or, if you are adventurous, you could look at Con Kolivas desktop scheduler patches, which aim to optimize desktop experience. This is really hard to measure and somewhat controversial — many people swear by it, while others are skeptical. (There's a Linux Weekly News article on the latest iteration at The MuQSS CPU scheduler — currently behind a paywall but will become free on May 4th.)

1

you'll want to look into the nice and renice utilities. To give your process a higher CPU priority you have to have root/sudo privileges. You can either use nice to start the process with a higher priority or renice to change it to a higher priority afterward.

(terminal1):~# nice -n -10 sleep 100
(terminal2):~# top -b -n1 | grep sleep
23580 root      10 -10    4508   1244   1156 S 0.000 0.008   0:00.00 sleep
(terminal1):~# sleep 100
(terminal2):~# top -b -n1 | grep sleep
23888 root      20   0    4508   1316   1228 S 0.000 0.008   0:00.00 sleep
(terminal2):~# renice -n -10 23888
23888 (process ID) old priority 0, new priority -10
(terminal2):~# top -b -n1 | grep sleep
23888 root      10 -10    4508   1356   1268 S 0.000 0.008   0:00.00 sleep
  • your answers prompts me to be more specific. The issue is not changing niceness once but by default for all future processes of a specific programme. – ingli Apr 28 '17 at 7:59
  • Unfortunately, to my knowledge, I don't think there's any established method of doing that per program. I know there is per user in the limits.conf, but I don't know of a way per program. A work-around might be to move the executable for that program to a slightly different name. Then create a simple bashscript for that program under its name that executes the renamed program with the adjusted nice value? I've never tested something like that though. – TopHat Apr 28 '17 at 15:48

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.