{"id":18399,"date":"2024-11-18T16:45:12","date_gmt":"2024-11-18T08:45:12","guid":{"rendered":"https:\/\/fwq.ai\/blog\/18399\/"},"modified":"2024-11-18T16:45:12","modified_gmt":"2024-11-18T08:45:12","slug":"%e5%b8%b8%e7%94%a8%e7%9a%84linux%e6%9f%a5%e7%9c%8b%e8%bf%9b%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/18399\/","title":{"rendered":"\u5e38\u7528\u7684linux\u67e5\u770b\u8fdb\u7a0b"},"content":{"rendered":"<blockquote><p>\n  \u5e38\u7528\u7684 linux \u67e5\u770b\u8fdb\u7a0b\u547d\u4ee4\u6709\uff1aps\uff1a\u7b80\u6d01\u663e\u793a\u5f53\u524d\u8fdb\u7a0b\uff1btop\uff1a\u4ea4\u4e92\u5f0f\u754c\u9762\u5b9e\u65f6\u663e\u793a\u8fdb\u7a0b\u4fe1\u606f\uff1bpstree\uff1a\u4ee5\u6811\u5f62\u7ed3\u6784\u663e\u793a\u8fdb\u7a0b\u53ca\u5176\u5b50\u8fdb\u7a0b\uff1bpidof\uff1a\u6839\u636e\u540d\u79f0\u67e5\u627e\u8fdb\u7a0b pid\uff1bkill\uff1a\u5411\u8fdb\u7a0b\u53d1\u9001\u4fe1\u53f7\uff08\u4f8b\u5982\u7ec8\u6b62\u6216\u8bf7\u6c42\u9000\u51fa\uff09\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/17\/2024081719071920351.jpg\" class=\"aligncenter\" title=\"\u5e38\u7528\u7684linux\u67e5\u770b\u8fdb\u7a0b\u63d2\u56fe\" alt=\"\u5e38\u7528\u7684linux\u67e5\u770b\u8fdb\u7a0b\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5e38\u7528\u7684 Linux \u67e5\u770b\u8fdb\u7a0b\u547d\u4ee4<\/strong><\/p>\n<p>Linux \u7cfb\u7edf\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u53ef\u7528\u4e8e\u67e5\u770b\u548c\u7ba1\u7406\u8fdb\u7a0b\u3002\u4ee5\u4e0b\u662f\u5e38\u7528\u7684 Linux \u67e5\u770b\u8fdb\u7a0b\u547d\u4ee4\uff1a<\/p>\n<p><strong>1. ps<\/strong><\/p>\n<p>ps \u547d\u4ee4\u662f\u6700\u57fa\u672c\u4e5f\u662f\u6700\u5e38\u89c1\u7684\u67e5\u770b\u8fdb\u7a0b\u547d\u4ee4\u3002\u5b83\u4ee5\u7b80\u6d01\u7684\u5f62\u5f0f\u5217\u51fa\u5f53\u524d\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\u3002<\/p>\n<p>\u8bed\u6cd5\uff1aps [\u9009\u9879]<\/p>\n<p>\u5e38\u7528\u9009\u9879\uff1a<\/p>\n<ul>\n<li>a\uff1a\u663e\u793a\u6240\u6709\u8fdb\u7a0b\uff0c\u5305\u62ec\u5176\u4ed6\u7528\u6237\u7684\u8fdb\u7a0b\u3002<\/li>\n<li>x\uff1a\u663e\u793a\u6240\u6709\u8fdb\u7a0b\uff0c\u65e0\u8bba\u5176\u7ec8\u7aef\u5982\u4f55\u3002<\/li>\n<li>u\uff1a\u663e\u793a\u8fdb\u7a0b\u6240\u6709\u8005\u7684\u7528\u6237\u540d\u3002<\/li>\n<\/ul>\n<p><strong>2. top<\/strong><\/p>\n<p>top \u547d\u4ee4\u63d0\u4f9b\u4e86\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u754c\u9762\uff0c\u5b9e\u65f6\u663e\u793a\u7cfb\u7edf\u8fdb\u7a0b\u7684\u4fe1\u606f\u3002<\/p>\n<p>\u8bed\u6cd5\uff1atop [\u9009\u9879]<\/p>\n<p>\u5e38\u7528\u9009\u9879\uff1a<\/p>\n<ul>\n<li>d\uff1a\u8bbe\u7f6e\u8fdb\u7a0b\u5217\u8868\u66f4\u65b0\u7684\u5ef6\u8fdf\uff08\u4ee5\u79d2\u4e3a\u5355\u4f4d\uff09\u3002<\/li>\n<li>s\uff1a\u6839\u636e CPU \u4f7f\u7528\u7387\u6392\u5e8f\u8fdb\u7a0b\u3002<\/li>\n<li>c\uff1a\u663e\u793a\u547d\u4ee4\u884c\u53c2\u6570\u3002<\/li>\n<\/ul>\n<p><strong>3. pstree<\/strong><\/p>\n<p>pstree \u547d\u4ee4\u4ee5\u6811\u5f62\u7ed3\u6784\u663e\u793a\u8fdb\u7a0b\u53ca\u5176\u5b50\u8fdb\u7a0b\u3002<\/p>\n<p>\u8bed\u6cd5\uff1apstree [\u9009\u9879]<\/p>\n<p>\u5e38\u7528\u9009\u9879\uff1a<\/p>\n<ul>\n<li>p\uff1a\u4f7f\u7528 PID \u663e\u793a\u8fdb\u7a0b\u6811\u3002<\/li>\n<li>h\uff1a\u4ec5\u663e\u793a\u8fdb\u7a0b\u540d\u79f0\u7684\u524d\u7f00\u3002<\/li>\n<li>c\uff1a\u663e\u793a\u547d\u4ee4\u884c\u53c2\u6570\u3002<\/li>\n<\/ul>\n<p><strong>4. pidof<\/strong><\/p>\n<p>pidof \u547d\u4ee4\u6839\u636e\u540d\u79f0\u67e5\u627e\u8fdb\u7a0b\u7684 PID\u3002<\/p>\n<p>\u8bed\u6cd5\uff1apidof [\u9009\u9879] [\u7a0b\u5e8f\u540d]<\/p>\n<p>\u5e38\u7528\u9009\u9879\uff1a<\/p>\n<ul>\n<li>s\uff1a\u4ec5\u6253\u5370\u6700\u5339\u914d\u8fdb\u7a0b\u7684 PID\u3002<\/li>\n<li>x\uff1a\u663e\u793a\u6240\u6709\u5339\u914d\u8fdb\u7a0b\u7684 PID\u3002<\/li>\n<\/ul>\n<p><strong>5. kill<\/strong><\/p>\n<p>kill \u547d\u4ee4\u7528\u4e8e\u5411\u8fdb\u7a0b\u53d1\u9001\u4fe1\u53f7\u3002<\/p>\n<p>\u8bed\u6cd5\uff1akill [\u9009\u9879] [PID \u6216\u4fe1\u53f7]<\/p>\n<p>\u5e38\u7528\u9009\u9879\uff1a<\/p>\n<ul>\n<li>-9\uff1a\u53d1\u9001 SIGKILL \u4fe1\u53f7\uff0c\u7acb\u5373\u7ec8\u6b62\u8fdb\u7a0b\u3002<\/li>\n<li>-15\uff1a\u53d1\u9001 SIGTERM \u4fe1\u53f7\uff0c\u8bf7\u6c42\u8fdb\u7a0b\u6b63\u5e38\u9000\u51fa\u3002<\/li>\n<\/ul>\n<p>\u901a\u8fc7\u4f7f\u7528\u8fd9\u4e9b\u547d\u4ee4\uff0c\u60a8\u53ef\u4ee5\u8f7b\u677e\u67e5\u770b\u548c\u7ba1\u7406 Linux \u7cfb\u7edf\u4e0a\u7684\u8fdb\u7a0b\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5e38\u7528\u7684\u67e5\u770b\u8fdb\u7a0b\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>\u5e38\u7528\u7684 linux \u67e5\u770b\u8fdb\u7a0b\u547d\u4ee4\u6709\uff1aps\uff1a\u7b80\u6d01\u663e\u793a\u5f53\u524d\u8fdb\u7a0b\uff1btop\uff1a\u4ea4\u4e92\u5f0f\u754c\u9762\u5b9e\u65f6\u663e\u793a\u8fdb\u7a0b\u4fe1\u606f\uff1bpstree\uff1a\u4ee5\u6811\u5f62\u7ed3\u6784\u663e\u793a\u8fdb\u7a0b\u53ca\u5176\u5b50\u8fdb\u7a0b\uff1bpidof\uff1a\u6839\u636e\u540d\u79f0\u67e5\u627e\u8fdb\u7a0b pid\uff1bkill\uff1a\u5411\u8fdb\u7a0b\u53d1\u9001\u4fe1\u53f7\uff08\u4f8b\u5982\u7ec8\u6b62\u6216\u8bf7\u6c42\u9000\u51fa\uff09\u3002 \u5e38\u7528\u7684 Linux \u67e5\u770b\u8fdb\u7a0b\u547d\u4ee4 Linux \u7cfb\u7edf\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u53ef\u7528\u4e8e\u67e5\u770b\u548c\u7ba1\u7406\u8fdb\u7a0b\u3002\u4ee5\u4e0b\u662f\u5e38\u7528\u7684 Linux \u67e5\u770b\u8fdb\u7a0b\u547d\u4ee4\uff1a 1. ps ps \u547d\u4ee4\u662f\u6700\u57fa\u672c\u4e5f\u662f\u6700\u5e38\u89c1\u7684\u67e5\u770b\u8fdb\u7a0b\u547d\u4ee4\u3002\u5b83\u4ee5\u7b80\u6d01\u7684\u5f62\u5f0f\u5217\u51fa\u5f53\u524d\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\u3002 \u8bed\u6cd5\uff1aps [\u9009\u9879] \u5e38\u7528\u9009\u9879\uff1a a\uff1a\u663e\u793a\u6240\u6709\u8fdb\u7a0b\uff0c\u5305\u62ec\u5176\u4ed6\u7528\u6237\u7684\u8fdb\u7a0b\u3002 x\uff1a\u663e\u793a\u6240\u6709\u8fdb\u7a0b\uff0c\u65e0\u8bba\u5176\u7ec8\u7aef\u5982\u4f55\u3002 u\uff1a\u663e\u793a\u8fdb\u7a0b\u6240\u6709\u8005\u7684\u7528\u6237\u540d\u3002 2. top top \u547d\u4ee4\u63d0\u4f9b\u4e86\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u754c\u9762\uff0c\u5b9e\u65f6\u663e\u793a\u7cfb\u7edf\u8fdb\u7a0b\u7684\u4fe1\u606f\u3002 \u8bed\u6cd5\uff1atop [\u9009\u9879] \u5e38\u7528\u9009\u9879\uff1a d\uff1a\u8bbe\u7f6e\u8fdb\u7a0b\u5217\u8868\u66f4\u65b0\u7684\u5ef6\u8fdf\uff08\u4ee5\u79d2\u4e3a\u5355\u4f4d\uff09\u3002 s\uff1a\u6839\u636e CPU \u4f7f\u7528\u7387\u6392\u5e8f\u8fdb\u7a0b\u3002 c\uff1a\u663e\u793a\u547d\u4ee4\u884c\u53c2\u6570\u3002 3. pstree pstree \u547d\u4ee4\u4ee5\u6811\u5f62\u7ed3\u6784\u663e\u793a\u8fdb\u7a0b\u53ca\u5176\u5b50\u8fdb\u7a0b\u3002 \u8bed\u6cd5\uff1apstree [\u9009\u9879] \u5e38\u7528\u9009\u9879\uff1a p\uff1a\u4f7f\u7528 PID \u663e\u793a\u8fdb\u7a0b\u6811\u3002 h\uff1a\u4ec5\u663e\u793a\u8fdb\u7a0b\u540d\u79f0\u7684\u524d\u7f00\u3002 c\uff1a\u663e\u793a\u547d\u4ee4\u884c\u53c2\u6570\u3002 4. pidof pidof \u547d\u4ee4\u6839\u636e\u540d\u79f0\u67e5\u627e\u8fdb\u7a0b\u7684 PID\u3002 \u8bed\u6cd5\uff1apidof [\u9009\u9879] [\u7a0b\u5e8f\u540d] \u5e38\u7528\u9009\u9879\uff1a s\uff1a\u4ec5\u6253\u5370\u6700\u5339\u914d\u8fdb\u7a0b\u7684 [&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-18399","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18399","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=18399"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18399\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=18399"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=18399"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=18399"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}