Linux Tutorial Blog

Your regular Linux tutorial source!

Solution: Gently killing a process

rechosen | 31 January, 2007 14:52

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 SIGQUIT. This solution describes how.

Please note that, if a process is not responding at all, chances are that it won't respond to a SIGQUIT. You can then try giving it a SIGKILL (just use the commands listed below but replace SIGQUIT 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 SIGQUIT this way:

killall -s SIGQUIT <processname>

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

kill -s SIGQUIT <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 crond
root      2067  0.0  0.1   5184   640 ?        Ss   10:29   0:00 crond
rechosen  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 bind
rechosen  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.

Comments

Re: Solution: Gently killing a process

stnzgr | 31/03/2007, 21:51

one can also use the "pidof" command. Eg: pidof bash

Very nice site btw

壁面収納

壁面収納 | 23/10/2008, 09:56

相変わらず壁面収納見晴らしはいい。新たに二カ所の指摘をするだけですみました。今日、家具の搬入でしたその新居に壁面収納を。

国際結婚

国際結婚 | 23/10/2008, 11:41

次女国際結婚しましたお姉ちゃんは控えめ美女さんですが次女はアクティヴ美女さんです。我娘を国際結婚美女呼ばわり日本初来日の国際結婚。

階段昇降機

階段昇降機 | 23/10/2008, 13:13

からくり階段昇降機技術を応用した介護用機器としての階段昇降機は、前回の階段昇降機作業で安全装置の取り付けが終了しました。

ホストクラブ

ホストクラブ | 23/10/2008, 15:42

カナダからの手紙なんだこれと思ってたら、ホストクラブこれか亮ちゃんホストクラブだしでも、その姿を見てレイニーの頃のホストクラブだ。

クレジットカード 現金化

クレジットカード 現金化 | 23/10/2008, 18:43

即日クレジットカード 現金化でキャッシングが確実に無審査でクレジットカード現金化利用できる画期的な方法があります。

クレジットカード 現金化

クレジットカード 現金化 | 23/10/2008, 19:01

即日クレジットカード 現金化でキャッシングが確実に無審査でクレジットカード現金化利用できる画期的な方法があります。

Add comment

(optional, will not be published)
(optional)

<><