next up previous
Next: Aliases Up: Introduction to the Linux Previous: Memory Management

Managing jobs

If a machine has too much to do it is said to be overloaded. In Linux the load of a machine is defined as the number of processes that are ready to run. If several computationally-intensive calculations are running simultaneously this may be more than 1. There are two schools of thought regarding loads of greater than 1, but basically you should try to keep the load low and definitely less than 2 if possible (unless you have a dual-CPU machine of course).

If your machine is overloaded it means there are always processes ready and waiting to have a share of the computer's time. When the load is high, you might find even typing on the keyboard takes several seconds to appear on the screen. This is not generally A Good Thing.

The simplest course of action to take when the machine is overloaded is to identify the jobs taking up the most time, and stop them. We do this using the kill command, followed by the PID of the process we wish to kill. Ordinarily you may only kill processes that you started. If the process has in fact gone wrong it is possible that it will ignore the kill command - in this case you can ask kill to be a little more insistent with the kill -9 argument, again followed by the PID.

A less severe course of action is to tell a process to `be nice' and give priority to other processes. We do this with the renice command,

[phasnip@mijpnb1 ~]$ renice +15 2216
2216: old priority 0, new priority 15

The `niceness' is measured from -20 to +20, although the negative numbers are reserved for important system processes. By default all user processes have a niceness of 0, so +15 in the example above is pretty nice! There isn't much of a disadvantage in renice-ing a calculation because most user processes don't actually take much CPU time. This changes if there are several computationally-intensive processes, and you may want to renice all of them.

If you know at the start that you want a program to have a niceness level then you can start it with the nice command,

[phasnip@mijpnb1 ~]$ nice +15 myprogram &

The niceness level is also reported by top in the fourth column (NI).


next up previous
Next: Aliases Up: Introduction to the Linux Previous: Memory Management
Phil Hasnip 2007-08-23