Basic Unix Appendix D: Killing Inactive Processes
Question:
I had to close a connection window; how do I tell Unix that I'm no longer logged in?
How do I stop programs I can't get back into to quit?
Answer:
Stopping a program is referred to as "killing a process." In order to kill a process, you'll need to do two things: first, use the ps command to find out what the process number is, and then use the kill</TT> command to stop the process.
- Type "ps -ef | grep myusername" (no quotes) at the ">" prompt.
You'll get output formatted like this:
myusername 21414 17383 0 11:57:25 pts/29 0:00 mail myusername 23477 17383 0 12:16:08 pts/29 0:00 grep myusername myusername 21513 21414 0 11:58:34 pts/29 0:00 /usr/local/bin/tcsh -c /usr/local/bin/less myusername 17383 17380 0 11:23:25 pts/29 0:02 -tcsh myusername 21515 21513 0 11:58:34 pts/29 0:00 /usr/local/bin/less
- Look at the lines, and find the oldest row (see the starting times in the middle -- fifth column) which has "-tcsh" in the far right column.
- Type "kill -9 #####" (again, no quotes) where ##### is the entry
in the second column for that row. That will kill the old process.
The tcsh process is the "shell" -- the basic "display a > and wait for the person to tell me what program to run" program that all other programs run over. Usually killing a tcsh program will kill all the programs run in that session. However, if it doesn't, simply repeat this step for all other programs which don't end automatically.
Last updated: 10/03/06