|
Running Long Jobsnicing programsRunning long jobs tends to slow a machine down very significantly. This can significantly impede other users in attempting to use the machine. Therefore, the polite thing to do is to run long jobs at a lower priority, thus ensuring that other users are not as significantly affected. The commands to do this are nice (1) and renice (8).
Any program which you expect will run for more than one or two minutes should be run with nice. Nice is a command which will execute a program at a lower than normal priority. If you realize after running a program that it is going to run longer than a couple of minutes, renice will lower the priority of a running process. Unfortunately, there are two versions of nice, one a shell built-in command, and another which resides in /bin. The /bin/nice version is recommended. If you just run nice, you will get the shell built-in command instead. Therefore, you should always specify /bin/nice.
In order to run a command using nice, use a syntax like % /bin/nice -number command Command is the program you want to run, including all command line arguments; just insert whatever you would normally type to run the program. Number is a priority level. Higher numbers are lower priorities, with a default of 0 if you just run a program without nice. The lowest possible priority corresponds to a number of 19. If your program will run for more than 10 or 15 minutes, you should probably use 19, which means your program will run only when no other process wants the CPU. For shorter programs, a 4 or 5 should be sufficient. A 0 is the default priority for running programs. So if you have a very long job to run called foobar, your command line would look something like % /bin/nice -19 foobar If you ran foobar without realizing that it would be a very long running program, you can use renice to alter its priority. Watch out, though; renice will only lower a program's priority, so if you make the priority too low, you can't raise it again. This simply means your program might take a long time to run. The syntax for renice is % /usr/ucb/renice number PID where PID is the process ID; the command ps (1) will tell you this. So for example, our foobar command would be something like: % foobar & (runs foobar in the background) % ps " PID TTY TIME COMD " 7112 pts/105 0:09 foobar % /bin/renice 19 7112
Notes:
Copyright (c) HMC Computer Science Department.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1
or any later version published by the Free Software Foundation;
with the no Invariant Sections, with no
Front-Cover Texts, and with no Back-Cover Texts.
A copy of the license is included in the section entitled ``GNU Free Documentation License.''
HMC Computer Science Department Contact Information |