{"id":18391,"date":"2024-11-18T17:19:05","date_gmt":"2024-11-18T09:19:05","guid":{"rendered":"https:\/\/fwq.ai\/blog\/18391\/"},"modified":"2024-11-18T17:19:05","modified_gmt":"2024-11-18T09:19:05","slug":"linux%e6%9f%a5%e7%9c%8b%e8%bf%9b%e7%a8%8b%e7%9a%84%e5%91%bd%e4%bb%a4%e6%98%af%e4%bb%80%e4%b9%88","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/18391\/","title":{"rendered":"linux\u67e5\u770b\u8fdb\u7a0b\u7684\u547d\u4ee4\u662f\u4ec0\u4e48"},"content":{"rendered":"<blockquote><p>\n  linux \u64cd\u4f5c\u7cfb\u7edf\u63d0\u4f9b\u4e00\u7cfb\u5217\u547d\u4ee4\u6765\u67e5\u770b\u8fdb\u7a0b\uff0c\u5206\u522b\u662f\uff1aps\uff1a\u67e5\u770b\u8fdb\u7a0b\u8be6\u7ec6\u4fe1\u606f\uff08pid\u3001\u540d\u79f0\u3001\u547d\u4ee4\u884c\u3001\u7528\u6237\u3001cpu\/\u5185\u5b58\u4f7f\u7528\u7387\uff09top\uff1a\u4ea4\u4e92\u5f0f\u76d1\u89c6\u5668\uff0c\u663e\u793a\u8fdb\u7a0b\u6d3b\u52a8\uff08cpu\/\u5185\u5b58\u4f7f\u7528\u7387\u3001\u542f\u52a8\u65f6\u95f4\u7b49\uff09pgrep\uff1a\u901a\u8fc7\u540d\u79f0\u641c\u7d22\u8fdb\u7a0b\uff08\u8f93\u51fa pid\uff09pidof\uff1a\u901a\u8fc7\u540d\u79f0\u641c\u7d22\u8fdb\u7a0b\uff08\u8f93\u51fa pid \u5217\u8868\uff09pstree\uff1a\u4ee5\u6811\u5f62\u7ed3\u6784\u663e\u793a\u8fdb\u7a0b\u5c42\u6b21\u7ed3\u6784kill\uff1a\u5411\u8fdb\u7a0b\u53d1\u9001\u4fe1\u53f7\uff08\u901a\u5e38\u4e0e pid \u4e00\u8d77\u4f7f\u7528\uff09\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/17\/2024081718582220562.jpg\" class=\"aligncenter\" title=\"linux\u67e5\u770b\u8fdb\u7a0b\u7684\u547d\u4ee4\u662f\u4ec0\u4e48\u63d2\u56fe\" alt=\"linux\u67e5\u770b\u8fdb\u7a0b\u7684\u547d\u4ee4\u662f\u4ec0\u4e48\u63d2\u56fe\" \/><\/p>\n<p><strong>\u67e5\u770b Linux \u8fdb\u7a0b\u7684\u547d\u4ee4<\/strong><\/p>\n<p>Linux \u64cd\u4f5c\u7cfb\u7edf\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u547d\u4ee4\u6765\u67e5\u770b\u8fdb\u7a0b\uff0c\u5176\u4e2d\u6700\u5e38\u7528\u7684\u5982\u4e0b\uff1a<\/p>\n<p><strong>1. ps \u547d\u4ee4<\/strong><\/p>\n<p>ps \u547d\u4ee4\u662f\u67e5\u770b\u8fdb\u7a0b\u4fe1\u606f\u7684\u6807\u51c6\u547d\u4ee4\u3002\u5b83\u8f93\u51fa\u6709\u5173\u5f53\u524d\u6b63\u5728\u8fd0\u884c\u8fdb\u7a0b\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u5305\u62ec\u8fdb\u7a0b ID (PID)\u3001\u8fdb\u7a0b\u540d\u79f0\u3001\u547d\u4ee4\u884c\u53c2\u6570\u3001\u7528\u6237\u3001CPU \u4f7f\u7528\u7387\u548c\u5185\u5b58\u4f7f\u7528\u7387\u3002<\/p>\n<pre>ps aux<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. top \u547d\u4ee4<\/strong><\/p>\n<p>top \u547d\u4ee4\u662f\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u8fdb\u7a0b\u76d1\u89c6\u5668\uff0c\u5b83\u4ee5\u5b9e\u65f6\u65b9\u5f0f\u663e\u793a\u8fdb\u7a0b\u6d3b\u52a8\u3002\u5b83\u63d0\u4f9b\u6709\u5173\u8fdb\u7a0b CPU \u4f7f\u7528\u7387\u3001\u5185\u5b58\u4f7f\u7528\u7387\u3001\u542f\u52a8\u65f6\u95f4\u548c\u5176\u4ed6\u7edf\u8ba1\u4fe1\u606f\u7684\u53ef\u6392\u5e8f\u5217\u8868\u3002<\/p>\n<pre>top<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3. pgrep \u547d\u4ee4<\/strong><\/p>\n<p>pgrep \u547d\u4ee4\u901a\u8fc7\u540d\u79f0\u641c\u7d22\u8fdb\u7a0b\u3002\u5b83\u8f93\u51fa\u6307\u5b9a\u8fdb\u7a0b\u7684 PID\u3002<\/p>\n<pre>pgrep bash<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>4. pidof \u547d\u4ee4<\/strong><\/p>\n<p>pidof \u547d\u4ee4\u4e0e pgrep \u7c7b\u4f3c\uff0c\u4f46\u5b83\u901a\u8fc7\u540d\u79f0\u641c\u7d22\u8fdb\u7a0b\u7684 PID\uff0c\u5e76\u4ee5\u7a7a\u683c\u5206\u9694\u7684\u5217\u8868\u5f62\u5f0f\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n<pre>pidof -x bash<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>5. pstree \u547d\u4ee4<\/strong><\/p>\n<p>pstree \u547d\u4ee4\u4ee5\u6811\u5f62\u7ed3\u6784\u663e\u793a\u8fdb\u7a0b\u5c42\u6b21\u7ed3\u6784\u3002\u5b83\u5c55\u793a\u4e86\u7236\u8fdb\u7a0b\u548c\u5b50\u8fdb\u7a0b\u4e4b\u95f4\u7684\u5173\u7cfb\u3002<\/p>\n<pre>pstree<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>6. kill \u547d\u4ee4<\/strong><\/p>\n<p>kill \u547d\u4ee4\u7528\u4e8e\u5411\u8fdb\u7a0b\u53d1\u9001\u4fe1\u53f7\u3002\u5b83\u901a\u5e38\u4e0e PID \u4e00\u8d77\u4f7f\u7528\u3002<\/p>\n<pre>kill -9 PID<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u67e5\u770b\u8fdb\u7a0b\u7684\u547d\u4ee4\u662f\u4ec0\u4e48\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>linux \u64cd\u4f5c\u7cfb\u7edf\u63d0\u4f9b\u4e00\u7cfb\u5217\u547d\u4ee4\u6765\u67e5\u770b\u8fdb\u7a0b\uff0c\u5206\u522b\u662f\uff1aps\uff1a\u67e5\u770b\u8fdb\u7a0b\u8be6\u7ec6\u4fe1\u606f\uff08pid\u3001\u540d\u79f0\u3001\u547d\u4ee4\u884c\u3001\u7528\u6237\u3001cpu\/\u5185\u5b58\u4f7f\u7528\u7387\uff09top\uff1a\u4ea4\u4e92\u5f0f\u76d1\u89c6\u5668\uff0c\u663e\u793a\u8fdb\u7a0b\u6d3b\u52a8\uff08cpu\/\u5185\u5b58\u4f7f\u7528\u7387\u3001\u542f\u52a8\u65f6\u95f4\u7b49\uff09pgrep\uff1a\u901a\u8fc7\u540d\u79f0\u641c\u7d22\u8fdb\u7a0b\uff08\u8f93\u51fa pid\uff09pidof\uff1a\u901a\u8fc7\u540d\u79f0\u641c\u7d22\u8fdb\u7a0b\uff08\u8f93\u51fa pid \u5217\u8868\uff09pstree\uff1a\u4ee5\u6811\u5f62\u7ed3\u6784\u663e\u793a\u8fdb\u7a0b\u5c42\u6b21\u7ed3\u6784kill\uff1a\u5411\u8fdb\u7a0b\u53d1\u9001\u4fe1\u53f7\uff08\u901a\u5e38\u4e0e pid \u4e00\u8d77\u4f7f\u7528\uff09 \u67e5\u770b Linux \u8fdb\u7a0b\u7684\u547d\u4ee4 Linux \u64cd\u4f5c\u7cfb\u7edf\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u547d\u4ee4\u6765\u67e5\u770b\u8fdb\u7a0b\uff0c\u5176\u4e2d\u6700\u5e38\u7528\u7684\u5982\u4e0b\uff1a 1. ps \u547d\u4ee4 ps \u547d\u4ee4\u662f\u67e5\u770b\u8fdb\u7a0b\u4fe1\u606f\u7684\u6807\u51c6\u547d\u4ee4\u3002\u5b83\u8f93\u51fa\u6709\u5173\u5f53\u524d\u6b63\u5728\u8fd0\u884c\u8fdb\u7a0b\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u5305\u62ec\u8fdb\u7a0b ID (PID)\u3001\u8fdb\u7a0b\u540d\u79f0\u3001\u547d\u4ee4\u884c\u53c2\u6570\u3001\u7528\u6237\u3001CPU \u4f7f\u7528\u7387\u548c\u5185\u5b58\u4f7f\u7528\u7387\u3002 ps aux \u767b\u5f55\u540e\u590d\u5236 2. top \u547d\u4ee4 top \u547d\u4ee4\u662f\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u8fdb\u7a0b\u76d1\u89c6\u5668\uff0c\u5b83\u4ee5\u5b9e\u65f6\u65b9\u5f0f\u663e\u793a\u8fdb\u7a0b\u6d3b\u52a8\u3002\u5b83\u63d0\u4f9b\u6709\u5173\u8fdb\u7a0b CPU \u4f7f\u7528\u7387\u3001\u5185\u5b58\u4f7f\u7528\u7387\u3001\u542f\u52a8\u65f6\u95f4\u548c\u5176\u4ed6\u7edf\u8ba1\u4fe1\u606f\u7684\u53ef\u6392\u5e8f\u5217\u8868\u3002 top \u767b\u5f55\u540e\u590d\u5236 3. pgrep \u547d\u4ee4 pgrep \u547d\u4ee4\u901a\u8fc7\u540d\u79f0\u641c\u7d22\u8fdb\u7a0b\u3002\u5b83\u8f93\u51fa\u6307\u5b9a\u8fdb\u7a0b\u7684 PID\u3002 pgrep bash \u767b\u5f55\u540e\u590d\u5236 4. pidof \u547d\u4ee4 pidof \u547d\u4ee4\u4e0e pgrep \u7c7b\u4f3c\uff0c\u4f46\u5b83\u901a\u8fc7\u540d\u79f0\u641c\u7d22\u8fdb\u7a0b\u7684 PID\uff0c\u5e76\u4ee5\u7a7a\u683c\u5206\u9694\u7684\u5217\u8868\u5f62\u5f0f\u8f93\u51fa\u7ed3\u679c\u3002 pidof -x bash \u767b\u5f55\u540e\u590d\u5236 5. pstree [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-18391","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18391","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=18391"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18391\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=18391"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=18391"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=18391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}