{"id":18374,"date":"2024-11-18T13:02:51","date_gmt":"2024-11-18T05:02:51","guid":{"rendered":"https:\/\/fwq.ai\/blog\/18374\/"},"modified":"2024-11-18T13:02:51","modified_gmt":"2024-11-18T05:02:51","slug":"linux%e6%80%8e%e4%b9%88%e6%9f%a5%e7%9c%8b%e5%bd%93%e5%89%8d%e8%bf%9b%e7%a8%8b%e4%bf%a1%e6%81%af","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/18374\/","title":{"rendered":"linux\u600e\u4e48\u67e5\u770b\u5f53\u524d\u8fdb\u7a0b\u4fe1\u606f"},"content":{"rendered":"<blockquote><p>\n  \u5982\u4f55\u67e5\u770b\u5f53\u524d\u8fdb\u7a0b\u4fe1\u606f\uff1f\u5728 linux \u7cfb\u7edf\u4e2d\uff0c\u67e5\u770b\u5f53\u524d\u8fdb\u7a0b\u4fe1\u606f\u6709\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a\u4f7f\u7528 ps \u547d\u4ee4\uff0c\u663e\u793a\u5f53\u524d\u8fd0\u884c\u8fdb\u7a0b\u7684\u57fa\u672c\u4fe1\u606f\uff0c\u5982 pid\u3001\u8fdb\u7a0b\u540d\u79f0\u3001\u7528\u6237\u548c\u8d44\u6e90\u4f7f\u7528\u60c5\u51b5\u3002\u4f7f\u7528 top \u547d\u4ee4\uff0c\u63d0\u4f9b\u8fdb\u7a0b\u7684\u5b9e\u65f6\u89c6\u56fe\uff0c\u6309 cpu \u6216\u5185\u5b58\u4f7f\u7528\u7387\u6392\u5e8f\u3002\u4f7f\u7528 pstree \u547d\u4ee4\uff0c\u751f\u6210\u8fdb\u7a0b\u6811\u72b6\u56fe\uff0c\u5c55\u793a\u8fdb\u7a0b\u53ca\u5176\u5b50\u8fdb\u7a0b\u3002\u67e5\u770b \/proc \u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\uff0c\u8be5\u76ee\u5f55\u5305\u542b\u6bcf\u4e2a\u8fdb\u7a0b\u7684\u5177\u4f53\u4fe1\u606f\uff0c\u5982 \/proc\/[pid]\/status \u4e2d\u7684\u8fdb\u7a0b\u72b6\u6001\u4fe1\u606f\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/17\/2024081718425263771.jpg\" class=\"aligncenter\" title=\"linux\u600e\u4e48\u67e5\u770b\u5f53\u524d\u8fdb\u7a0b\u4fe1\u606f\u63d2\u56fe\" alt=\"linux\u600e\u4e48\u67e5\u770b\u5f53\u524d\u8fdb\u7a0b\u4fe1\u606f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u67e5\u770b\u5f53\u524d\u8fdb\u7a0b\u4fe1\u606f<\/strong><\/p>\n<p>\u5728 Linux \u7cfb\u7edf\u4e2d\uff0c\u67e5\u770b\u5f53\u524d\u8fdb\u7a0b\u4fe1\u606f\u6709\u51e0\u79cd\u65b9\u6cd5\uff1a<\/p>\n<p><strong>1. ps \u547d\u4ee4<\/strong><\/p>\n<p>ps \u547d\u4ee4\u7528\u4e8e\u663e\u793a\u5f53\u524d\u6d3b\u52a8\u8fdb\u7a0b\u7684\u4fe1\u606f\u3002\u57fa\u672c\u7528\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre>ps<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u5217\u51fa\u6240\u6709\u5f53\u524d\u8fd0\u884c\u7684\u8fdb\u7a0b\u53ca\u5176\u76f8\u5173\u4fe1\u606f\uff0c\u5305\u62ec\u8fdb\u7a0b ID (PID)\u3001\u8fdb\u7a0b\u540d\u79f0\u3001\u7528\u6237\u3001CPU \u4f7f\u7528\u7387\u548c\u5185\u5b58\u4f7f\u7528\u7387\u3002<\/p>\n<p><strong>2. top \u547d\u4ee4<\/strong><\/p>\n<p>top \u547d\u4ee4\u662f\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u7a0b\u5e8f\uff0c\u63d0\u4f9b\u7cfb\u7edf\u4e2d\u6240\u6709\u8fdb\u7a0b\u7684\u5b9e\u65f6\u89c6\u56fe\u3002\u5b83\u6309 CPU \u4f7f\u7528\u7387\u3001\u5185\u5b58\u4f7f\u7528\u7387\u6216\u5176\u4ed6\u6307\u6807\u5bf9\u8fdb\u7a0b\u8fdb\u884c\u6392\u5e8f\u3002<\/p>\n<pre>top<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3. pstree \u547d\u4ee4<\/strong><\/p>\n<p>pstree \u547d\u4ee4\u751f\u6210\u4e00\u4e2a\u8fdb\u7a0b\u6811\u72b6\u56fe\uff0c\u663e\u793a\u6bcf\u4e2a\u8fdb\u7a0b\u53ca\u5176\u5b50\u8fdb\u7a0b\u3002<\/p>\n<pre>pstree<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>4. proc \u76ee\u5f55<\/strong><\/p>\n<p>\/proc \u662f\u4e00\u4e2a\u865a\u62df\u6587\u4ef6\u7cfb\u7edf\uff0c\u5176\u4e2d\u5305\u542b\u6bcf\u4e2a\u8fdb\u7a0b\u7684\u4fe1\u606f\u3002\u8981\u83b7\u53d6\u7279\u5b9a\u8fdb\u7a0b\u7684\u4fe1\u606f\uff0c\u53ef\u4ee5\u67e5\u770b\u5176 \/proc\/[PID] \u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\/proc\/[PID]\/status \u6587\u4ef6\u5305\u542b\u6709\u5173\u8fdb\u7a0b\u72b6\u6001\u7684\u4fe1\u606f\u3002<\/p>\n<p><strong>\u5177\u4f53\u4fe1\u606f<\/strong><\/p>\n<p>\u4f7f\u7528\u8fd9\u4e9b\u547d\u4ee4\uff0c\u4f60\u53ef\u4ee5\u83b7\u53d6\u4ee5\u4e0b\u6709\u5173\u5f53\u524d\u8fdb\u7a0b\u7684\u4fe1\u606f\uff1a<\/p>\n<ul>\n<li> <strong>\u8fdb\u7a0b ID (PID)<\/strong>\uff1a\u8fdb\u7a0b\u7684\u552f\u4e00\u6807\u8bc6\u7b26\u3002<\/li>\n<li> <strong>\u8fdb\u7a0b\u540d\u79f0<\/strong>\uff1a\u8fdb\u7a0b\u7684\u53ef\u6267\u884c\u6587\u4ef6\u540d\u3002<\/li>\n<li> <strong>\u7528\u6237<\/strong>\uff1a\u62e5\u6709\u8be5\u8fdb\u7a0b\u7684\u7528\u6237\u3002<\/li>\n<li> <strong>\u72b6\u6001<\/strong>\uff1a\u8fdb\u7a0b\u7684\u5f53\u524d\u72b6\u6001\uff08\u4f8b\u5982\uff0c\u8fd0\u884c\u3001\u4f11\u7720\u3001\u50f5\u5c38\uff09\u3002<\/li>\n<li> <strong>CPU \u4f7f\u7528\u7387<\/strong>\uff1a\u8fdb\u7a0b\u6d88\u8017\u7684 CPU \u65f6\u95f4\u767e\u5206\u6bd4\u3002<\/li>\n<li> <strong>\u5185\u5b58\u4f7f\u7528\u7387<\/strong>\uff1a\u8fdb\u7a0b\u5360\u7528\u7684\u7269\u7406\u5185\u5b58\u91cf\u3002<\/li>\n<li> <strong>\u7236\u8fdb\u7a0b ID<\/strong>\uff1a\u521b\u5efa\u8be5\u8fdb\u7a0b\u7684\u8fdb\u7a0b\u7684 PID\u3002<\/li>\n<li> <strong>\u5b50\u8fdb\u7a0b<\/strong>\uff1a\u7ed9\u5b9a\u8fdb\u7a0b\u7684\u5b50\u8fdb\u7a0b\u3002<\/li>\n<li> <strong>\u547d\u4ee4\u884c\u53c2\u6570<\/strong>\uff1a\u8fdb\u7a0b\u542f\u52a8\u65f6\u4f20\u9012\u7ed9\u5b83\u7684\u53c2\u6570\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u67e5\u770b\u5f53\u524d\u8fdb\u7a0b\u4fe1\u606f\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>\u5982\u4f55\u67e5\u770b\u5f53\u524d\u8fdb\u7a0b\u4fe1\u606f\uff1f\u5728 linux \u7cfb\u7edf\u4e2d\uff0c\u67e5\u770b\u5f53\u524d\u8fdb\u7a0b\u4fe1\u606f\u6709\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a\u4f7f\u7528 ps \u547d\u4ee4\uff0c\u663e\u793a\u5f53\u524d\u8fd0\u884c\u8fdb\u7a0b\u7684\u57fa\u672c\u4fe1\u606f\uff0c\u5982 pid\u3001\u8fdb\u7a0b\u540d\u79f0\u3001\u7528\u6237\u548c\u8d44\u6e90\u4f7f\u7528\u60c5\u51b5\u3002\u4f7f\u7528 top \u547d\u4ee4\uff0c\u63d0\u4f9b\u8fdb\u7a0b\u7684\u5b9e\u65f6\u89c6\u56fe\uff0c\u6309 cpu \u6216\u5185\u5b58\u4f7f\u7528\u7387\u6392\u5e8f\u3002\u4f7f\u7528 pstree \u547d\u4ee4\uff0c\u751f\u6210\u8fdb\u7a0b\u6811\u72b6\u56fe\uff0c\u5c55\u793a\u8fdb\u7a0b\u53ca\u5176\u5b50\u8fdb\u7a0b\u3002\u67e5\u770b \/proc \u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\uff0c\u8be5\u76ee\u5f55\u5305\u542b\u6bcf\u4e2a\u8fdb\u7a0b\u7684\u5177\u4f53\u4fe1\u606f\uff0c\u5982 \/proc\/[pid]\/status \u4e2d\u7684\u8fdb\u7a0b\u72b6\u6001\u4fe1\u606f\u3002 \u5982\u4f55\u67e5\u770b\u5f53\u524d\u8fdb\u7a0b\u4fe1\u606f \u5728 Linux \u7cfb\u7edf\u4e2d\uff0c\u67e5\u770b\u5f53\u524d\u8fdb\u7a0b\u4fe1\u606f\u6709\u51e0\u79cd\u65b9\u6cd5\uff1a 1. ps \u547d\u4ee4 ps \u547d\u4ee4\u7528\u4e8e\u663e\u793a\u5f53\u524d\u6d3b\u52a8\u8fdb\u7a0b\u7684\u4fe1\u606f\u3002\u57fa\u672c\u7528\u6cd5\u5982\u4e0b\uff1a ps \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u5c06\u5217\u51fa\u6240\u6709\u5f53\u524d\u8fd0\u884c\u7684\u8fdb\u7a0b\u53ca\u5176\u76f8\u5173\u4fe1\u606f\uff0c\u5305\u62ec\u8fdb\u7a0b ID (PID)\u3001\u8fdb\u7a0b\u540d\u79f0\u3001\u7528\u6237\u3001CPU \u4f7f\u7528\u7387\u548c\u5185\u5b58\u4f7f\u7528\u7387\u3002 2. top \u547d\u4ee4 top \u547d\u4ee4\u662f\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u7a0b\u5e8f\uff0c\u63d0\u4f9b\u7cfb\u7edf\u4e2d\u6240\u6709\u8fdb\u7a0b\u7684\u5b9e\u65f6\u89c6\u56fe\u3002\u5b83\u6309 CPU \u4f7f\u7528\u7387\u3001\u5185\u5b58\u4f7f\u7528\u7387\u6216\u5176\u4ed6\u6307\u6807\u5bf9\u8fdb\u7a0b\u8fdb\u884c\u6392\u5e8f\u3002 top \u767b\u5f55\u540e\u590d\u5236 3. pstree \u547d\u4ee4 pstree \u547d\u4ee4\u751f\u6210\u4e00\u4e2a\u8fdb\u7a0b\u6811\u72b6\u56fe\uff0c\u663e\u793a\u6bcf\u4e2a\u8fdb\u7a0b\u53ca\u5176\u5b50\u8fdb\u7a0b\u3002 pstree \u767b\u5f55\u540e\u590d\u5236 4. proc \u76ee\u5f55 \/proc \u662f\u4e00\u4e2a\u865a\u62df\u6587\u4ef6\u7cfb\u7edf\uff0c\u5176\u4e2d\u5305\u542b\u6bcf\u4e2a\u8fdb\u7a0b\u7684\u4fe1\u606f\u3002\u8981\u83b7\u53d6\u7279\u5b9a\u8fdb\u7a0b\u7684\u4fe1\u606f\uff0c\u53ef\u4ee5\u67e5\u770b\u5176 \/proc\/[PID] \u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\/proc\/[PID]\/status \u6587\u4ef6\u5305\u542b\u6709\u5173\u8fdb\u7a0b\u72b6\u6001\u7684\u4fe1\u606f\u3002 [&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-18374","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18374","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=18374"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18374\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=18374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=18374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=18374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}