4 Nisan 2009 Cumartesi

Kill process in Linux or terminate a process in UNIX or Linux systems

Step #1: First, you need to find out process PID (process id)
Use ps command or pidof command to find out process ID (PID).

Syntax:ps aux grep processnamepidof processname
For example if process name is lighttpd, you can use any one of the following command to obtain process ID:

# ps aux grep lighttpd

OR
use pidof command which is use to find the process ID of a running program:

# pidof lighttpd

Step #2: kill process using PID (process id)
Above command tell you PID (3486) of lighttpd process. Now kill process using this PID:

# kill 3486

OR

# kill -9 3486

Where,
-9 is special Kill signal, which will kill the process.

killall command examples
DO NOT USE killall command on UNIX system (Linux only command). You can also use killall command. The killall command kill processes by name (no need to find PID):

# killall -9 lighttpd

Kill Firefox process:
# killall -9 firefox-bin

As I said earlier killall on UNIX system does something else. It kills all process and not just specific process. Do not use killall on UNIX system (use kill -9).

Hiç yorum yok:

Yorum Gönder