{"id":18377,"date":"2024-11-18T15:41:56","date_gmt":"2024-11-18T07:41:56","guid":{"rendered":"https:\/\/fwq.ai\/blog\/18377\/"},"modified":"2024-11-18T15:41:56","modified_gmt":"2024-11-18T07:41:56","slug":"linux%e6%80%8e%e4%b9%88%e6%9f%a5%e7%9c%8b%e8%bf%9b%e7%a8%8b%e7%8a%b6%e6%80%81","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/18377\/","title":{"rendered":"linux\u600e\u4e48\u67e5\u770b\u8fdb\u7a0b\u72b6\u6001"},"content":{"rendered":"<blockquote><p>\n  \u7b54\u6848\uff1a \u901a\u8fc7\u4f7f\u7528 ps\u3001top\u3001pstree\u3001cat \/proc\/[pid]\/status \u7b49\u547d\u4ee4\uff0c\u53ef\u4ee5\u5728 linux \u4e2d\u67e5\u770b\u8fdb\u7a0b\u72b6\u6001\u3002ps \u547d\u4ee4\u53ef\u663e\u793a\u8fdb\u7a0b\u7684\u57fa\u672c\u4fe1\u606f\uff0c\u5305\u62ec pid \u548c cpu \u4f7f\u7528\u7387\u3002top \u547d\u4ee4\u63d0\u4f9b\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u754c\u9762\uff0c\u6301\u7eed\u66f4\u65b0\u8fdb\u7a0b\u4fe1\u606f\uff0c\u5982 cpu \u4f7f\u7528\u7387\u548c\u5185\u5b58\u4f7f\u7528\u7387\u3002pstree \u547d\u4ee4\u663e\u793a\u8fdb\u7a0b\u6811\uff0c\u5c55\u793a\u8fdb\u7a0b\u53ca\u5176\u5b50\u8fdb\u7a0b\u4e4b\u95f4\u7684\u5173\u7cfb\u3002cat \/proc\/[pid]\/status \u547d\u4ee4\u63d0\u4f9b\u6709\u5173\u8fdb\u7a0b\u72b6\u6001\u7684\u66f4\u8be6\u7ec6\u7684\u4fe1\u606f\u3002\u5176\u4ed6\u547d\u4ee4\uff0c\u5982 pidof\u3001kill \u548c renice\uff0c\u4e5f\u53ef\u7528\u4e8e\u67e5\u770b\u6216\u7ba1\u7406\u8fdb\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/17\/2024081718454312805.jpg\" class=\"aligncenter\" title=\"linux\u600e\u4e48\u67e5\u770b\u8fdb\u7a0b\u72b6\u6001\u63d2\u56fe\" alt=\"linux\u600e\u4e48\u67e5\u770b\u8fdb\u7a0b\u72b6\u6001\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728 Linux \u4e2d\u67e5\u770b\u8fdb\u7a0b\u72b6\u6001<\/strong><\/p>\n<p><strong>\u524d\u8a00<\/strong><br \/>\u4e86\u89e3\u8fdb\u7a0b\u7684\u72b6\u6001\u5bf9\u4e8e\u8bca\u65ad\u548c\u7ba1\u7406 Linux \u7cfb\u7edf\u81f3\u5173\u91cd\u8981\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5404\u79cd\u547d\u4ee4\u6765\u68c0\u67e5\u8fdb\u7a0b\u7684\u5f53\u524d\u72b6\u6001\u3002<\/p>\n<p><strong>\u65b9\u6cd5<\/strong><\/p>\n<p><strong>1. ps \u547d\u4ee4<\/strong><br \/>ps \u547d\u4ee4\u662f\u6700\u5e38\u7528\u7684\u5de5\u5177\u4e4b\u4e00\uff0c\u7528\u4e8e\u67e5\u770b\u8fdb\u7a0b\u7684\u72b6\u6001\u3002\u5b83\u53ef\u4ee5\u663e\u793a\u6709\u5173\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\u7684\u57fa\u672c\u4fe1\u606f\uff0c\u5305\u62ec\u8fdb\u7a0b ID (PID)\u3001\u7528\u6237\u3001CPU \u4f7f\u7528\u7387\u548c\u5185\u5b58\u4f7f\u7528\u7387\u3002<\/p>\n<pre>ps -ef<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. top \u547d\u4ee4<\/strong><br \/>top \u547d\u4ee4\u63d0\u4f9b\u4e86\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u7684\u8fdb\u7a0b\u72b6\u6001\u76d1\u89c6\u754c\u9762\u3002\u5b83\u6301\u7eed\u66f4\u65b0\u8fdb\u7a0b\u4fe1\u606f\uff0c\u5305\u62ec CPU \u4f7f\u7528\u7387\u3001\u5185\u5b58\u4f7f\u7528\u7387\u3001\u7ebf\u7a0b\u6570\u548c\u547d\u4ee4\u884c\u53c2\u6570\u3002<\/p>\n<pre>top<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3. pstree \u547d\u4ee4<\/strong><br \/>pstree \u547d\u4ee4\u663e\u793a\u4e00\u4e2a\u8fdb\u7a0b\u6811\uff0c\u5c55\u793a\u8fdb\u7a0b\u53ca\u5176\u5b50\u8fdb\u7a0b\u4e4b\u95f4\u7684\u5173\u7cfb\u3002\u8fd9\u6709\u52a9\u4e8e\u53ef\u89c6\u5316\u7cfb\u7edf\u4e2d\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\u5c42\u6b21\u7ed3\u6784\u3002<\/p>\n<pre>pstree<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>4. cat \/proc\/[PID]\/status \u547d\u4ee4<\/strong><br \/>\u6bcf\u4e2a\u8fdb\u7a0b\u90fd\u6709\u4e00\u4e2a \/proc \u76ee\u5f55\u4e0b\u7684\u6761\u76ee\uff0c\u5176\u4e2d\u5305\u542b\u6709\u5173\u8be5\u8fdb\u7a0b\u7684\u8be6\u7ec6\u4fe1\u606f\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 cat \u547d\u4ee4\u67e5\u770b\u8be5\u6761\u76ee\u4e2d\u7684 status \u6587\u4ef6\uff0c\u4ee5\u83b7\u53d6\u6709\u5173\u8fdb\u7a0b\u72b6\u6001\u7684\u66f4\u8be6\u7ec6\u7684\u4fe1\u606f\u3002<\/p>\n<pre>cat \/proc\/[PID]\/status<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>5. Other Commands<\/strong><br \/>\u4ee5\u4e0b\u5176\u4ed6\u547d\u4ee4\u4e5f\u53ef\u4ee5\u7528\u4e8e\u67e5\u770b\u8fdb\u7a0b\u72b6\u6001\uff1a<\/p>\n<ul>\n<li> <strong>pidof \u547d\u4ee4\uff1a<\/strong>\u6839\u636e\u8fdb\u7a0b\u540d\u79f0\u67e5\u627e\u8fdb\u7a0b ID\u3002<\/li>\n<li> <strong>kill \u547d\u4ee4\uff1a<\/strong>\u7ec8\u6b62\u8fdb\u7a0b\u3002<\/li>\n<li> <strong>renice \u547d\u4ee4\uff1a<\/strong>\u4fee\u6539\u8fdb\u7a0b\u7684\u8c03\u5ea6\u4f18\u5148\u7ea7\u3002<\/li>\n<\/ul>\n<p><strong>\u7ed3\u8bba<\/strong><br \/>\u901a\u8fc7\u4f7f\u7528\u8fd9\u4e9b\u547d\u4ee4\uff0c\u6211\u4eec\u53ef\u4ee5\u6df1\u5165\u4e86\u89e3 Linux \u7cfb\u7edf\u4e2d\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\u7684\u72b6\u6001\u3002\u8fd9\u4e9b\u4fe1\u606f\u5bf9\u4e8e\u6545\u969c\u6392\u9664\u3001\u6027\u80fd\u4f18\u5316\u548c\u8d44\u6e90\u7ba1\u7406\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u67e5\u770b\u8fdb\u7a0b\u72b6\u6001\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>\u7b54\u6848\uff1a \u901a\u8fc7\u4f7f\u7528 ps\u3001top\u3001pstree\u3001cat \/proc\/[pid]\/status \u7b49\u547d\u4ee4\uff0c\u53ef\u4ee5\u5728 linux \u4e2d\u67e5\u770b\u8fdb\u7a0b\u72b6\u6001\u3002ps \u547d\u4ee4\u53ef\u663e\u793a\u8fdb\u7a0b\u7684\u57fa\u672c\u4fe1\u606f\uff0c\u5305\u62ec pid \u548c cpu \u4f7f\u7528\u7387\u3002top \u547d\u4ee4\u63d0\u4f9b\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u754c\u9762\uff0c\u6301\u7eed\u66f4\u65b0\u8fdb\u7a0b\u4fe1\u606f\uff0c\u5982 cpu \u4f7f\u7528\u7387\u548c\u5185\u5b58\u4f7f\u7528\u7387\u3002pstree \u547d\u4ee4\u663e\u793a\u8fdb\u7a0b\u6811\uff0c\u5c55\u793a\u8fdb\u7a0b\u53ca\u5176\u5b50\u8fdb\u7a0b\u4e4b\u95f4\u7684\u5173\u7cfb\u3002cat \/proc\/[pid]\/status \u547d\u4ee4\u63d0\u4f9b\u6709\u5173\u8fdb\u7a0b\u72b6\u6001\u7684\u66f4\u8be6\u7ec6\u7684\u4fe1\u606f\u3002\u5176\u4ed6\u547d\u4ee4\uff0c\u5982 pidof\u3001kill \u548c renice\uff0c\u4e5f\u53ef\u7528\u4e8e\u67e5\u770b\u6216\u7ba1\u7406\u8fdb \u5982\u4f55\u5728 Linux \u4e2d\u67e5\u770b\u8fdb\u7a0b\u72b6\u6001 \u524d\u8a00\u4e86\u89e3\u8fdb\u7a0b\u7684\u72b6\u6001\u5bf9\u4e8e\u8bca\u65ad\u548c\u7ba1\u7406 Linux \u7cfb\u7edf\u81f3\u5173\u91cd\u8981\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5404\u79cd\u547d\u4ee4\u6765\u68c0\u67e5\u8fdb\u7a0b\u7684\u5f53\u524d\u72b6\u6001\u3002 \u65b9\u6cd5 1. ps \u547d\u4ee4ps \u547d\u4ee4\u662f\u6700\u5e38\u7528\u7684\u5de5\u5177\u4e4b\u4e00\uff0c\u7528\u4e8e\u67e5\u770b\u8fdb\u7a0b\u7684\u72b6\u6001\u3002\u5b83\u53ef\u4ee5\u663e\u793a\u6709\u5173\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\u7684\u57fa\u672c\u4fe1\u606f\uff0c\u5305\u62ec\u8fdb\u7a0b ID (PID)\u3001\u7528\u6237\u3001CPU \u4f7f\u7528\u7387\u548c\u5185\u5b58\u4f7f\u7528\u7387\u3002 ps -ef \u767b\u5f55\u540e\u590d\u5236 2. top \u547d\u4ee4top \u547d\u4ee4\u63d0\u4f9b\u4e86\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u7684\u8fdb\u7a0b\u72b6\u6001\u76d1\u89c6\u754c\u9762\u3002\u5b83\u6301\u7eed\u66f4\u65b0\u8fdb\u7a0b\u4fe1\u606f\uff0c\u5305\u62ec CPU \u4f7f\u7528\u7387\u3001\u5185\u5b58\u4f7f\u7528\u7387\u3001\u7ebf\u7a0b\u6570\u548c\u547d\u4ee4\u884c\u53c2\u6570\u3002 top \u767b\u5f55\u540e\u590d\u5236 3. pstree \u547d\u4ee4pstree \u547d\u4ee4\u663e\u793a\u4e00\u4e2a\u8fdb\u7a0b\u6811\uff0c\u5c55\u793a\u8fdb\u7a0b\u53ca\u5176\u5b50\u8fdb\u7a0b\u4e4b\u95f4\u7684\u5173\u7cfb\u3002\u8fd9\u6709\u52a9\u4e8e\u53ef\u89c6\u5316\u7cfb\u7edf\u4e2d\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\u5c42\u6b21\u7ed3\u6784\u3002 pstree \u767b\u5f55\u540e\u590d\u5236 4. cat \/proc\/[PID]\/status [&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-18377","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18377","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=18377"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18377\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=18377"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=18377"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=18377"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}