home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Unix Power ToolsUnix Power ToolsSearch this book

23.7. System Overloaded? Try Stopping Some Jobs

If your computer is barely crawling, you can kill (Section 24.12) some processes, but you'll have to start them again later. On many Unix systems, you can renice ( Section 26.7) the processes, but you won't be able to raise the priority again later, after the system speeds up, unless you're the superuser (Section 1.18).

If you don't need your results right away (and you won't get them, anyway, if the system is crawling!), try stopping some jobs. The best candidates are "CPU-eaters" like formatters, compilers, and any job that runs up a lot of time quickly in the ps (Section 24.5) or time (Section 26.2) reports. Start them again later, and the jobs will take up where they left off.

If the job is in the foreground, just press CTRL-z (Section 23.3) to stop it. If the job is running in the background and you're running csh or tcsh, use the shell's stop command with a job identifier -- for example, stop %3 or stop %cc.

On other shells -- even shells without job control (!) -- you can use kill (Section 24.12) with the -STOP signal and either the job number or process ID number. The csh and tcsh command stop does this for you. On other shells, if you'd like, you can add an alias named stop to the shell setup file (Section 3.3). Later, when the system speeds up, put the job back into the background with bg or into the foreground with fg. For example:

bash$ alias stop='kill -STOP'
bash$ jobs
[1]+  Running                 g++ hugeprog.cc &
bash$ stop %1
[1]+  Stopped (signal)        g++ hugeprog.cc
    ...later...
bash$ bg %1
[1]+ g++ hugeprog.cc &

-- JP



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.