Enter your email address:

Delivered by FeedBurner

How to: Set or change the priority of a process - nice and renice


StumbleUpon Toolbar

Console logo

How to assign and reassign priority to Linux commands or processes, to optimize your CPU ussage

You may have seen this problem with your Linux sometimes, you are working with your normal applications, like browsing the web, using Open Office or any other thing, and then Linux start a cron process or you start a make command, and all the other applications slow down.

Well you can solve that by entering different priorities to different applications, this is done with the nice and renice commands.

Lets say you need to compile a program, and do not want it to eat all the processor power and attention, so you can still perform other actions.

Enter:

nice make all

Here the nice command will increase the niceness by 10 (the default increment if nothing else is indicated).

And how nice work?, well it adjust priority from -20 (most favorable scheduling) to -19 (least favorable scheduling).

Only root can assign a lower priority (negative number) while the rest of users can only decrease the priority of a process.

You an also reassign the priority while a command is running, to do this you need to use renice command, or better using htop

See the picture below:

htop Linux command screen shot

You just need to highlight the command you want to act on, (using arrow keys) and then press F7 to increase priority, or F8 to decrease priority. Note that you need to own the process if you are not root, and also if you are not root, you can only decrease priority.

nice man page

renice man page

Trackback URL for this post:

http://www.go2linux.org/trackback/379
StumbleUpon Toolbar

 If you like this article, subscribe to our full rss

If this article was somehow useful for you, you can leave something in the tip's jar

Please post your question in our forum and use comments only to leave your comments about the article, thanks.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

Captcha
This question is for testing whether you are a human visitor and to prevent automated spam submissions.

This site is proudly hosted at Bluefur Hosting