Blog/ How to kill an unresponsive process in Unix

I am sure you would have come across Windows' processes that hang. And I am sure you know what to do. CTL + ALT + DEL and kill the process using the Task Manager. In this article, we'll how to do that on Unix using command line.

Here are the steps:

1) See the PID of the process that has hung and you want to kill. Execute the following command in the terminal.

ps aux

This command will list all the processes running on your system. Here is the format:

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0  29364  2864 ?        Ss   Sep15   0:01 /sbin/init
root         2  0.0  0.0      0     0 ?        S    Sep15   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S    Sep15   0:00 [ksoftirqd/0]
root         5  0.0  0.0      0     0 ?        S<   Sep15   0:00 [kworker/0:0H]
root         7  0.0  0.0      0     0 ?        S    Sep15   0:00 [rcu_sched]
root         8  0.0  0.0      0     0 ?        S    Sep15   0:00 [rcuos/0]
root         9  0.0  0.0      0     0 ?        S    Sep15   0:00 [rcuos/1]
root        10  0.0  0.0      0     0 ?        S    Sep15   0:00 [rcu_bh]
root      1026  0.0  0.1 248388 11928 ?        Ssl  Sep15   0:00 /usr/sbin/glusterd -p /var/run/glusterd.pid
root      1038  0.0  0.0  19188   764 ?        Ss   Sep15   0:10 /usr/sbin/irqbalance
syslog    1075  0.0  0.0 255844  1416 ?        Ssl  Sep15   0:00 rsyslogd
root      1084  0.0  0.0   4368   664 ?        Ss   Sep15   0:00 acpid -c /etc/acpi/events -s /var/run/acpid.socket

2) Note down the PID of the process I want to stop. As an example, let's assume that I want to stop the process /usr/sbin/glusterd. Its PID is 1026.

3) Execute the following command on the command line.

sudo kill 1026

Execute ps aux command again and make sure that your unresponsive program has been killed. If it's still present, execute the following on the command line.

sudo kill -9 1026

Now that should do it! :)

 
Ready to get started?REQUEST A QUOTE