Viewing and stopping processes

by: acul Monday, November 28th, 2011

Every program that runs on your system, including the shell itself and any commands that you might have issued, creates a process. You can get a list of all running process on your system by using the ps command. For exam- ple, entering the ps command on my system gives the following output:

ps -ax
PID TTY STAT TIME COMMAND
1 ? S 0:04 init [5]
2 ? SW 0:01 [keventd]
3 ? SW 0:00 [kapmd]
4 ? SWN 0:00 [ksoftirqd/0]
6 ? SW 0:00 [bdflush]

23580 ? S 1:38 /usr/lib/openoffice/
program/soffice.bin private:factory/swriter
23766 pts/1 R 0:00 ps ax

Sometimes processes don’t behave nicely and can stop responding or working as you expected. You can use the output of the ps command to find the process that is misbehaving and stop it. Notice in the preceding listing the column labeled PID: In this column is the Process ID number of the process. For example, take a look at the next-to-last PID, number 23580. If you follow the line beginning with 23580 across to the command column, you can see that this is the process started by OpenOffice. The command column always shows the command that started the process. If OpenOffice were not respond- ing, I could force it to stop running by using the kill command as follows:

kill -9 23580

The -9 in the command is referred to as a signal. In some cases, a running program can catch a signal and not act on the command. By using the -9, you are forcing the program to end because the -9 signal cannot be caught by a running program.

« | Home | »

 

Leave a Comment