September 15th 2007 07:43 pm

Being nice With Long Processes

Every once and a while, I find that I need to compile code on a machine where many other more important things are running. In my case, I generally find myself recompiling PHP on a machine that also runs my very active forum website [http://forums.reebosak.net] in addition to many other websites, including this one. Running a long build is not exactly the nicest thing to do to users who are trying to go about their normal browsing, where a long build would cause really long page loads since the processor is so busy. The way to deal with this is by being nice (and renice).

from the UNIX man page:

NAME

       nice - run a program with modified scheduling priority

DESCRIPTION

       Run  COMMAND  with an adjusted niceness, which affects process schedul-
       ing.  With no COMMAND, print the current  niceness.   Nicenesses  range
       from -20 (most favorable scheduling) to 19 (least favorable).

To set a processes niceness run it with the nice command:

[brien@toothbrush ~]$ nice -n 5 make // run make with +5 niceness (lower priority)
[brien@toothbrush ~]$ ps aux |grep make
brien      4560  0.0  0.1  5040 1180 pts/1    SN+  18:36  0:00 make
[brien@toothbrush ~]$ sudo renice -3 4560 // change the niceness of the process to -3 (higher priority)

No Comments yet »

Trackback URI | Comments RSS

Leave a Reply

You must be logged in to post a comment.

« Auto Converting PHP Objects to Strings using the __toString() ‘Magic Method’ | Terry Chay: Why PHP triumphs over Ruby »