{"id":180,"date":"2023-10-17T12:58:57","date_gmt":"2023-10-17T04:58:57","guid":{"rendered":"https:\/\/blog.quantoyo.com\/?p=180"},"modified":"2024-01-08T11:25:20","modified_gmt":"2024-01-08T03:25:20","slug":"linux-kill%e6%8c%87%e4%bb%a4%e7%a0%8d%e6%8e%89%e9%97%9c%e9%8d%b5%e7%a8%8b%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/blog.quantoyo.com\/?p=180","title":{"rendered":"Linux kill\u6307\u4ee4\u780d\u6389\u95dc\u9375\u7a0b\u5f0f"},"content":{"rendered":"\n<!--more-->\n\n\n\n<p>\u4f7f\u7528 kill \u53ef\u4ee5\u780d\u6389\u6a5f\u5668\u4e0a\u7684\u4e00\u500b\u6307\u5b9a\u7684pid <\/p>\n\n\n\n<pre class=\"wp-block-code has-light-gray-background-color has-background has-small-font-size\"><code>kill `ps aux |grep <span style=\"background-color: rgba(51, 51, 51, 0.2); font-size: inherit;\">TestServer<\/span><span style=\"font-size: inherit; background-color: initial;\"> |awk '{print $2}'`<\/span>\n<code>\u8a73\u89e3\uff1a\n\u5148\u4f7f\u7528 ps \u6307\u4ee4 \u53d6\u5f97 TestServer \u76f8\u95dc\u7684\u8cc7\u8a0a\uff0c\u63a5\u8457\u4f7f\u7528 pipeLine \u5c07\u53d6\u5f97\u7684\u8cc7\u8a0a\u8f49\u5230 awk \u8655\u7406\u3002\n\u9019\u908a awk \u53ea\u628a\u7b2c\u4e8c\u500b\u53c3\u6578\u5370\u51fa\u4f86\u3002\n\n\u201c `` <span style=\"background-color: initial; font-size: inherit;\">\u201d\u9019\u662f\u8981\u5c07\u88e1\u9762\u7684\u5b57\u50b3\u905e\u7d66kill \u4f7f\u7528\u7684\u65b9\u5f0f<\/span><\/code>\n\n1. \u5148\u4f7f\u7528ps \u6307\u4ee4\u6b63\u5e38\u627e\u51fa\u4f86 pid\n2. \u52a0awk\u6307\u4ee4\u6293\u53d6pid \n3. \u524d\u5f8c\u52a0\u4e0a``\n4. kill\u6389\u5168\u90e8<\/code><\/pre>\n\n\n\n<p>ps \u5f8c\u9762\u5e36\u7684\u53c3\u6578 aux<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>-a<\/td><td>\u986f\u793a\u6240\u6709\u4f7f\u7528\u8005\u7684 process<\/td><\/tr><tr><td>-u<\/td><td>\u986f\u793a\u76ee\u524d\u4f7f\u7528\u8005\u7684 process<\/td><\/tr><tr><td>-x<\/td><td>\u986f\u793a\u5305\u542b\u6c92\u6709\u7d42\u7aef\u7684 process<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>kill \u4f9d\u64da\u7576\u4e0b\u72c0\u614b\u6703\u6709\u4e0d\u540c\u7684\u5c64\u7d1a\uff0c\u5176\u4e2d -9 \u70ba\u5f37\u5236\u505c\u6b62\uff0c-15 \u70ba\u6b63\u5e38\u505c\u6b62\uff0c\u4ee5\u4e0b\u5217\u8868\u70ba\u5e38\u7528\u7684\u53c3\u6578\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>SIGHUP<\/td><td>1<\/td><td>\u7d42\u7aef\u6a5f\u65b7\u7dda\u5c0e\u81f4\u7684\u505c\u6b62<\/td><\/tr><tr><td>SIGINT<\/td><td>2<\/td><td>\u4e2d\u65b7 process\uff0c\u901a\u5e38\u900f\u904e\u9375\u76e4\u5feb\u901f\u9375 Ctrl+C \u767c\u9001<\/td><\/tr><tr><td>SIGKILL<\/td><td>9<\/td><td>\u5f37\u5236\u505c\u6b62 \u4efb\u4f55\u6b63\u5728\u57f7\u884c\u6216\u80cc\u666f\u57f7\u884c\u7684process\uff0c\u4e0d\u5141\u8a31\u5176\u6e05\u7406<\/td><\/tr><tr><td>SIGTERM<\/td><td>15<\/td><td>\u9019\u662f\u7d42\u6b62 Linux \u4e2d\u6b63\u5728\u904b\u884c\u7684 process \u7684\u9810\u8a2d\u4e14\u6700\u5b89\u5168\u7684\u65b9\u6cd5\u3002\u5b83\u5141\u8a31 process \u6b63\u5e38\u7d42\u6b62<\/td><\/tr><tr><td>SIGCONT<\/td><td>18<\/td><td>\u5c07 19 \u66ab\u505c\u7684 process \u91cd\u65b0\u555f\u52d5<\/td><\/tr><tr><td>SIGSTOP<\/td><td>19<\/td><td>\u66ab\u505c\u76ee\u524dprocess\u800c\u4e0d\u7d42\u6b62\u5b83\uff0c\u901a\u5e38\u900f\u904e\u9375\u76e4\u5feb\u901f\u9375 Ctrl+Z \u767c\u9001<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u53c3\u8003\u8cc7\u6599\uff1a<\/p>\n\n\n\n<p><a href=\"https:\/\/faculty.cs.niu.edu\/~hutchins\/csci480\/signals.htm\">https:\/\/faculty.cs.niu.edu\/~hutchins\/csci480\/signals.htm<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[41,40,37],"class_list":["post-180","post","type-post","status-publish","format-standard","hentry","category-technology","tag-awk","tag-kill","tag-linux"],"_links":{"self":[{"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=\/wp\/v2\/posts\/180","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=180"}],"version-history":[{"count":5,"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=\/wp\/v2\/posts\/180\/revisions"}],"predecessor-version":[{"id":411,"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=\/wp\/v2\/posts\/180\/revisions\/411"}],"wp:attachment":[{"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}