Using nice to control CPU usage and process priority

If you wish to run a command which typically uses a lot of CPU (for example, running tar on a large file), then you probably don’t want to bog down your whole system with it. Linux systems provide the nice command to control your process priority at runtime, or renice to change the priority of an already running process. The full manpage has help, but the command if very easy to use:

$ nice -n prioritylevel /command/to/run

The priority level runs from -20 (top priority) to 19 (lowest). For example, to run tar and gzip at a the lowest priority level:

$ nice -n 19 tar -czvf file.tar.gz bigfiletocompress

similarly, if you have a process running, use ps to find the process ID, and then use renice to change it’s priority level:

$ renice -n 19 -p 987 32

This would change processes 987 and 32 to priority level 19.

Share and Enjoy:
  • Twitter
  • del.icio.us
  • Digg
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Print
  • StumbleUpon

1 Trackbacks

You can leave a trackback using this URL: http://systembash.com/content/using-nice-to-control-cpu-usage-and-process-priority/trackback/

  1. By Dave Drager on September 4, 2008 at 12:07 am

    New blog post: Using nice to control CPU usage and process priority http://tinyurl.com/5pmc8m

Post a Comment

Your email is never shared. Required fields are marked *

*
*