< Day Day Up > |
If you issue the ps command and find that one of your processes is hung or if you start a large job that you want to stop, you can do so with the kill command. kill is a utility that sends a signal to the process you identify. You can kill any process that you own. In addition, superuser can kill almost any process on the system. To kill a process that you own, simply issue the kill command and the Process ID (PID). The following example shows issuing the ps command to search for find processes, killing a process, and checking to see that it has disappeared: # ps -ef | grep find root 29012 3555 4 19:05 pts/1 00:00:00 find / -name *.sh -print root 29021 28928 0 19:06 pts/3 00:00:00 grep find # kill 29012 # ps -ef | grep find root 29025 28928 0 19:06 pts/3 00:00:00 grep find # The example shows killing process 29012, which is a find command. We confirm that the process has indeed been killed by reissuing the ps command. You can kill several processes on the command line by issuing kill followed by a space-separated list of all of the process numbers you want to kill. Take special care when killing processes if you are logged in as superuser. You may adversely affect the way the system runs and have to manually restart processes or reboot the system. In the shell programming chapter, there are two shell programs to help you search for and then kill processes. |
< Day Day Up > |