The kill Command


The kill Command

When you use the kill command with a process, you stop whatever that process is doing. One hazard with commands of this nature is that if you are using a program like the vi editor and you kill it, you may lose your work as a result.

Although the kill command is mainly used to end a process, it can also be used to send signals to a process. Signals can be sent to indicate an action. There are actually many signals that you can use with the kill command. If you use the kill command with the l option, you can see a list of everything that Unix can signal with:

 >kill -l  1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL  5) SIGTRAP      6) SIGIOT       7) SIGBUS       8) SIGFPE  9) SIGKILL     10) SIGUSR1     11) SIGSEGV     12) SIGUSR2 13) SIGPIPE     14) SIGALRM     15) SIGTERM     17) SIGCHLD 18) SIGCONT     19) SIGSTOP     20) SIGTSTP     21) SIGTTIN 22) SIGTTOU     23) SIGURG      24) SIGXCPU     25) SIGXFSZ 26) SIGVTALRM   27) SIGPROF     28) SIGWINCH    29) SIGIO 30) SIGPWR 

Documentation for the software you run on your system often includes information on the signals to which it will respond. The most important signals you'll use are SIGHUP and SIGKILL. The SIGHUP signal will hang up and reload the server's process configuration information. SIGKILL should be pretty self-explanatory; KILL in all capital letters should help you remember that this is the signal to kill processes. To use the kill command, enter kill -<signal number> <process ID> <process ID> ....

For example, to kill process number 8832, type the following:

 >kill -9 8832 

If you look at the process listing again, PID 8832 will be gone. You've successfully killed it! Check by verifying with the ps command and make sure that the process has ended. You can also check with the jobs command as well.

Getting on Top The top command can be used to quickly identify running processes, and it continuously updates a list of them for you to view. It's really a great command when you want to know what your Unix system is doing. The top command can also help you see the amount of time being used by each process and the processes' priority.

To exit out of top, press Ctrl+c or q.


So now that you are comfortable working with commands such as top, jobs, ps, and kill, let's look at some of the other commands you will need to know to control processes within Unix, namely cron and at.



    SAMS Teach Yourself Unix in 10 Minutes
    Sams Teach Yourself Unix in 10 Minutes (2nd Edition)
    ISBN: 0672327643
    EAN: 2147483647
    Year: 2005
    Pages: 170

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net