-->
Previous | Table of Contents | Next |
Suppose you enter ps -f and see the following response:
UID PID PPID C STIME TTY TIME COMMAND chris 65 1 0 11:40:11 tty01 0:06 -bash chris 71 65 61 11:42:01 tty01 0:14 total_updt inventory chris 231 65 80 11:46:02 tty01 0:00 ps -f chris 187 53 60 15:32:01 tty02 123:45 crunch stats chris 53 1 0 15:31:34 tty02 1:06 -bash
To kill process 187, normally you would enter kill 187. If you then enter ps -f again and see that the process is still there, you know the process is set up to ignore the kill command. To kill it unconditionally, enter kill -9 187. When you enter ps -f again, you see that the process is no longer around.
CAUTION:
A disadvantage to using this unconditional version of the kill command is that kill -9 doesnt allow a process to finish what its doing before it terminates the process. If you use kill -9 with a program thats updating a file, you could lose the updated material or the entire file.Use the powerful kill -9 command responsibly. In most cases, you dont need the -9 option; the kill command, issued without arguments, stops most processes.
Termination of All Background Processes
To kill all background jobs, enter kill 0. Commands that run in the background sometimes initiate more than one process; tracking down all the PID numbers associated with the process you want to kill can be tedious. Because kill 0 terminates all processes started by the current shell, its a faster and less tedious way to terminate processes. Enter the jobs command to see what commands are running in the background for the current shell.
This chapter presented the commands you need to manage multiple processes. You saw that you run multiple processes whenever you put jobs in the background with the ampersand (&) or when you use pipes. You can schedule jobs at a specific time with the at command, at a time the system feels is appropriate with the batch command, and at regularly scheduled times with cron and crontab. For more information, see the following:
In addition, check out the man pages for the various commands discussed in this chapter.
Previous | Table of Contents | Next |