{"id":4259,"date":"2012-11-15T19:41:01","date_gmt":"2012-11-15T11:41:01","guid":{"rendered":"http:\/\/jpuyy.com\/?p=4259"},"modified":"2013-06-08T19:49:40","modified_gmt":"2013-06-08T11:49:40","slug":"linux-pkill-kill-killall","status":"publish","type":"post","link":"https:\/\/jpuyy.com\/?p=4259","title":{"rendered":"linux\u4e2dpkill\uff0ckill,killall\u7684\u7528\u6cd5"},"content":{"rendered":"<p>killall\u4e5f\u53ef\u4ee5\u8ddf\u8fdb\u7a0b\u540d<\/p>\n<p>killall &#8211; kill processes by name<\/p>\n<p>killall sends a signal to all processes running any of the specified commands. If no signal name is specified, SIGTERM is sent.<\/p>\n<p>kill \u662f\u8981\u636e\u8fdb\u7a0b\u53f7\u6765\u6740\u6b7b\u8fdb\u7a0b\uff0c\u52a0-9\u5f3a\u5236\u6740\u6b7b<\/p>\n<p>\u7ed3\u5408ps \u6216 pgrep<\/p>\n<p>pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to stdout. All the criteria have to match. For example,<\/p>\n<p>$ pgrep -u root sshd<\/p>\n<p>will only list the processes called sshd AND owned by root.<\/p>\n<p>\u4f46\u662f\u8fd9\u6837\u53ea\u4f1a\u663e\u793a\u8fdb\u7a0b\u53f7\uff0c\u600e\u4e48\u529e? \u6c38\u8fdc\u4e0d\u8981\u5fd8\u4e86man\u4e00\u4e0b<\/p>\n<p>man pgrep\u91cc\u7ed9\u51fa\u4e86\u5b9e\u4f8b<\/p>\n<p>\u6211\u8bd5\u4e86\u4e00\u4e0b\uff0c\u5982<\/p>\n<p>ps `pgrep -u www-data` \u6216\u8005 ps $(pgrep -u www-data) \u53ef\u4ee5\u67e5\u770b\u5230\u8be6\u7ec6\u7684\u5c5e\u4e8ewww-data\u7528\u6237\u7684\u8fdb\u7a0b<\/p>\n<p>root@debian:~# ps `pgrep -u www-data`<br \/>\nPID TTY STAT TIME COMMAND<br \/>\n3128 ? S 0:00 : worker process<br \/>\n12245 ? S 0:04 php-fpm: pool www<br \/>\n12246 ? S 0:04 php-fpm: pool www<br \/>\n12247 ? S 0:05 php-fpm: pool www<br \/>\n12248 ? S 0:06 php-fpm: pool www<br \/>\n12249 ? S 0:05 php-fpm: pool www<br \/>\n12250 ? S 0:05 php-fpm: pool www<\/p>\n","protected":false},"excerpt":{"rendered":"<p>killall\u4e5f\u53ef\u4ee5\u8ddf\u8fdb\u7a0b\u540d killall &#8211; kill processes by name killall sends a signal to all processes running any of the specified commands. If no signal name is specified, SIGTERM is sent. kill \u662f\u8981\u636e\u8fdb\u7a0b\u53f7\u6765\u6740\u6b7b\u8fdb\u7a0b\uff0c\u52a0-9\u5f3a\u5236\u6740\u6b7b \u7ed3\u5408ps \u6216 pgrep pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to stdout. All the [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-4259","post","type-post","status-publish","format-standard","hentry","category-life"],"_links":{"self":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/4259","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4259"}],"version-history":[{"count":2,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/4259\/revisions"}],"predecessor-version":[{"id":5053,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/4259\/revisions\/5053"}],"wp:attachment":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4259"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}