「Linux」killコマンドでプロセスを終了する方法

書式
kill -9 プロセスID
kill -KILL プロセスID
kill -SIGKILL プロセスID
使用例
1.プロセスの状態を確認
# ps aux | grep httpd

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
root 1374 0.0 0.2 275960 3904 ? Ss 318 0:04 /usr/sbin/httpd -DFOREGROUND
apache 1819 0.0 0.1 289836 2520 ? S 318 0:00 /usr/sbin/httpd -DFOREGROUND
apache 1820 0.0 0.1 1478756 2756 ? Sl 318 0:19 /usr/sbin/httpd -DFOREGROUND
apache 1821 0.0 0.1 1347620 2928 ? Sl 318 0:19 /usr/sbin/httpd -DFOREGROUND
apache 1822 0.0 0.1 1347620 2928 ? Sl 318 0:19 /usr/sbin/httpd -DFOREGROUND
root 296789 0.0 0.0 10308 1124 pts/0 R+ 13:16 0:00 grep --color=auto httpd
root 1374 0.0 0.2 275960 3904 ? Ss 3月18 0:04 /usr/sbin/httpd -DFOREGROUND apache 1819 0.0 0.1 289836 2520 ? S 3月18 0:00 /usr/sbin/httpd -DFOREGROUND apache 1820 0.0 0.1 1478756 2756 ? Sl 3月18 0:19 /usr/sbin/httpd -DFOREGROUND apache 1821 0.0 0.1 1347620 2928 ? Sl 3月18 0:19 /usr/sbin/httpd -DFOREGROUND apache 1822 0.0 0.1 1347620 2928 ? Sl 3月18 0:19 /usr/sbin/httpd -DFOREGROUND root 296789 0.0 0.0 10308 1124 pts/0 R+ 13:16 0:00 grep --color=auto httpd
root        1374  0.0  0.2 275960  3904 ?        Ss    3月18   0:04 /usr/sbin/httpd -DFOREGROUND
apache      1819  0.0  0.1 289836  2520 ?        S     3月18   0:00 /usr/sbin/httpd -DFOREGROUND
apache      1820  0.0  0.1 1478756 2756 ?        Sl    3月18   0:19 /usr/sbin/httpd -DFOREGROUND
apache      1821  0.0  0.1 1347620 2928 ?        Sl    3月18   0:19 /usr/sbin/httpd -DFOREGROUND
apache      1822  0.0  0.1 1347620 2928 ?        Sl    3月18   0:19 /usr/sbin/httpd -DFOREGROUND
root      296789  0.0  0.0  10308  1124 pts/0    R+   13:16   0:00 grep --color=auto httpd

2.プロセスID「1819」を止める
# kill -9 1819

プロセスID「1820」を止める
# kill -KILL 1820

プロセスID[1821]を止める
# kill -SIGKILL 1821

3.確認
# ps aux | grep httpd

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
root 1374 0.0 0.2 275960 4528 ? Ss 318 0:04 /usr/sbin/httpd -DFOREGROUND
apache 1822 0.0 0.1 1478756 3300 ? Sl 318 0:19 /usr/sbin/httpd -DFOREGROUND
apache 297379 0.1 0.4 290176 7416 ? S 13:17 0:00 /usr/sbin/httpd -DFOREGROUND
apache 297932 0.1 0.4 1347620 9140 ? Sl 13:19 0:00 /usr/sbin/httpd -DFOREGROUND
apache 299108 0.0 0.5 1347620 9196 ? Sl 13:22 0:00 /usr/sbin/httpd -DFOREGROUND
root 299423 0.0 0.0 10308 1152 pts/0 R+ 13:23 0:00 grep --color=auto httpd
root 1374 0.0 0.2 275960 4528 ? Ss 3月18 0:04 /usr/sbin/httpd -DFOREGROUND apache 1822 0.0 0.1 1478756 3300 ? Sl 3月18 0:19 /usr/sbin/httpd -DFOREGROUND apache 297379 0.1 0.4 290176 7416 ? S 13:17 0:00 /usr/sbin/httpd -DFOREGROUND apache 297932 0.1 0.4 1347620 9140 ? Sl 13:19 0:00 /usr/sbin/httpd -DFOREGROUND apache 299108 0.0 0.5 1347620 9196 ? Sl 13:22 0:00 /usr/sbin/httpd -DFOREGROUND root 299423 0.0 0.0 10308 1152 pts/0 R+ 13:23 0:00 grep --color=auto httpd
root        1374  0.0  0.2 275960  4528 ?        Ss    3月18   0:04 /usr/sbin/httpd -DFOREGROUND
apache      1822  0.0  0.1 1478756 3300 ?        Sl    3月18   0:19 /usr/sbin/httpd -DFOREGROUND
apache    297379  0.1  0.4 290176  7416 ?        S    13:17   0:00 /usr/sbin/httpd -DFOREGROUND
apache    297932  0.1  0.4 1347620 9140 ?        Sl   13:19   0:00 /usr/sbin/httpd -DFOREGROUND
apache    299108  0.0  0.5 1347620 9196 ?        Sl   13:22   0:00 /usr/sbin/httpd -DFOREGROUND
root      299423  0.0  0.0  10308  1152 pts/0    R+   13:23   0:00 grep --color=auto httpd

 

Linux

Posted by arkgame