Be Nice To Your Server: Setting Process Priorities

In a vast majority of cases, Linux does a fantastic job of automatically scheduling processes. The more urgent processes are given a higher priority, and the less urgent processes a lower priority. In rare circumstances, the scheduler might not prioritize processes as you would like. For example, backup processes could be taking up resources that you would rather be used serving web pages. If you would like to regain a bit control over process priorities, the nice and renice commands will give you some.

Setting Priorities

The nice command controls the priority of a process right when you start it. Here’s an example:

nice -n 19 ./ &

Running the nice command by itself just prints the current niceness of the shell, usually 0. (The niceness numbers range from a high of -20 to a low of 19. Niceness is like golf; the lower the number, the better off the process is.) The -n flag is needed to specify the niceness level. In the above example, is run in the background with the lowest possible niceness.

Changing Priorities

The nice command only sets the niceness right when a process is started. If you find yourself wanting to change the niceness of a process that is already running, the renice command handles that scenario.

renice 12 -p 73682

renice first takes the niceness level you want to set, then uses the -p flag to specify the number of the process you want to change. The ps command can help you track down the ID number of the process you want to renice.

Renice Sparingly

While setting a process’s niceness can help manage your server’s resources, it is not a panacea. The gains you might get from setting the proper niceness just might not be enough to handle the load on your server. Should this prove to be the case, do not hesitate to contact our Heroic SupportĀ® team. We will happily take a look at your server and make recommendations.


Liquid Web’s Heroic Support is always available to assist customers with this or any other issue. If you need our assistance please contact us:
Toll Free 1.800.580.4985
International 517.322.0434

Be Sociable, Share!

Published by

Here's 75 % off, Launch a New VPS Today. Find out why 30,000 customers have chosen our Best-in-Class Performance & 24x7 Heroic Support