06. Changing process priorities

As mentioned before, each process takes up a certain amount of CPU time. For every moment the CPU is busy running one process, another process loses valuable running time.

As you can imagine, there will be some instances when you are under time constraints and want to prioritize one job over others. Or other times you'll want to push a process back so that it can run quietly in the background while you tend to other things. To control such priorities, we may launch a program with the nice command, or modify a currently running process with renice.


The term niceness comes from how "nice" the process is, in terms of how much CPU time it hogs. A nice process (as you would imagine) doesn't take too much CPU time and shares the CPU liberally with other processes.

This range of values goes from -20 to 20, where the lower the niceness, the more prioritized the process is. Thus, a "mean" process (one that hogs system resources) would have values close to -20, while a nicer process is closer to 20. The default niceness of any program is 10.

Syntax for nice

There are several ways you can call on nice:

$ nice -12 python longProgram.py
$ nice -n 12 python longProgram.py
$ nice --adjustment=12 python longProgram.py

As you can tell, we call nice, then specify any arguments before we input a command.

Syntax for renice

We can use the renice command to alter the priority of an already running process without disrupting its operation.

$ renice priority [[-p] pids] [[-g] pgrps] [[-u] users]

You may specify a process via its PID with the -p option. If you want to change the priorities of all processes under a certain group or user, use the -g and -u options.

$ renice 5 -p 21649
# Prioritizes the process with pid 21649
$ renice 19 -u SarahMarsh
# Deprioritizes all processes belonging to user SarahMarsh

Take your Linux skills to the next level!

How Linux Works

Take your Linux skills to the next level! Try Linux & UNIX

In this completely revised second edition of the perennial best seller How Linux Works, author Brian Ward makes the concepts behind Linux internals accessible to anyone curious about the inner workings of the operating system. Inside, you'll find the kind of knowledge that normally comes from years of experience doing things the hard way.

$ Check price
39.9539.95Amazon 5 logo(114+ reviews)

More Linux & UNIX resources

Aching back from coding all day?

Inversion Therapy Table

Aching back from coding all day? Try Back Problems

Stretch out your back and relieve your back muscles with inversion therapy. This device counteracts the forces of gravity on the body by decompressing and elongating the spine. By using this product just ten minutes a day, you can be well on your way to improved circulation and posture while relieving muscle aches, back pain and stress.

$$ Check price
119.98119.98Amazon 4.5 logo(1,700+ reviews)

More Back Problems resources