Share on facebook
Share on twitter
Share on linkedin

Solution: Gently killing a process


Sometimes you somehow can’t quit a certain process, but you don’t want to lose all unsaved data by killing it. You can then try giving it a SIGTERM. This solution describes how.Please note that, if a process is not responding at all, chances are that it won’t respond to a SIGTERM. You can then try giving it a SIGKILL (just use the commands listed below but replace SIGTERM with SIGKILL). The signal SIGKILL has an even higher priority than SIGTERM, the signal that killall and kill defaultly give to a process.You can give all processes with a certain name a SIGTERM this way:

killall -s SIGTERM <processname>

Of course, you might also want to quit a process with a certain pid. You can do that this way:

kill -s SIGTERM <pid>

To find out a process’ pid, have a look at the list that this command generates:

ps aux

If you (partly) know the name of the process, you can also grep for it so you won’t have to read the whole list:

ps aux | grep <partoftheprocessname>

The above command consists of two parts: ps aux generates a list which is passed to grep by bash, and grep searches every line of ps aux’s output for the string <partoftheprocessname>. Grep’s searching is case-sensitive, you can also search case-insensitive this way:

ps aux | grep <partoftheprocessname> -i

By the way, you probably noticed that both command find themselves everytime you run them. This is normal, you should ignore this line. If the command only finds itself, then there is no process running of which the name contains <partoftheprocessname>. Example:

[rechosen@localhost ~]$ ps aux | grep crondroot 2067 0.0 0.1 5184 640 ? Ss 10:29 0:00 crondrechosen 6498 0.0 0.1 3912 652 pts/3 R+ 15:12 0:00 grep crond

In the above case, the process crond with pid 2067 is what you’re looking for. And in this case:

[rechosen@localhost ~]$ ps aux | grep bindrechosen 6514 0.0 0.1 3912 652 pts/3 R+ 15:14 0:00 grep bind

bind is not running, as grep only finds itself.


Get more insights, news, and assorted awesomeness around all things cloud learning.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?