{"id":18406,"date":"2024-11-18T16:25:29","date_gmt":"2024-11-18T08:25:29","guid":{"rendered":"https:\/\/fwq.ai\/blog\/18406\/"},"modified":"2024-11-18T16:25:29","modified_gmt":"2024-11-18T08:25:29","slug":"linux%e5%a6%82%e4%bd%95%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\/18406\/","title":{"rendered":"linux\u5982\u4f55\u67e5\u770b\u8fdb\u7a0b\u72b6\u6001"},"content":{"rendered":"<blockquote><p>\n  \u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 ps \u547d\u4ee4\u3001top \u547d\u4ee4\u3001pstree \u547d\u4ee4\u6216 proc \u6587\u4ef6\u7cfb\u7edf\u6765\u67e5\u770b linux \u8fdb\u7a0b\u72b6\u6001\u3002\u8fd9\u6709\u52a9\u4e8e\u76d1\u63a7\u8fdb\u7a0b\u6d3b\u52a8\u548c\u786e\u4fdd\u7cfb\u7edf\u5e73\u7a33\u8fd0\u884c\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/17\/2024081719140253245.jpg\" class=\"aligncenter\" title=\"linux\u5982\u4f55\u67e5\u770b\u8fdb\u7a0b\u72b6\u6001\u63d2\u56fe\" alt=\"linux\u5982\u4f55\u67e5\u770b\u8fdb\u7a0b\u72b6\u6001\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u67e5\u770b Linux \u8fdb\u7a0b\u72b6\u6001<\/strong><\/p>\n<p>\u5728 Linux \u7cfb\u7edf\u4e2d\uff0c\u67e5\u770b\u8fdb\u7a0b\u72b6\u6001\u81f3\u5173\u91cd\u8981\uff0c\u56e0\u4e3a\u5b83\u5141\u8bb8\u7cfb\u7edf\u7ba1\u7406\u5458\u548c\u7528\u6237\u76d1\u63a7\u7cfb\u7edf\u8fd0\u884c\u4e2d\u8fdb\u7a0b\u7684\u6d3b\u52a8\u3002\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u6cd5\u67e5\u770b\u8fdb\u7a0b\u72b6\u6001\u3002<\/p>\n<p><strong>1. \u4f7f\u7528 ps \u547d\u4ee4<\/strong><\/p>\n<p>ps \u547d\u4ee4\u662f\u6700\u5e38\u7528\u7684\u67e5\u770b\u8fdb\u7a0b\u72b6\u6001\u7684\u65b9\u6cd5\u3002\u5b83\u53ef\u4ee5\u663e\u793a\u7cfb\u7edf\u4e2d\u6240\u6709\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\u7684\u4fe1\u606f\u3002<\/p>\n<pre>ps -ef<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u547d\u4ee4\u5c06\u663e\u793a\u6bcf\u4e2a\u8fdb\u7a0b\u7684\u8fdb\u7a0b ID (PID)\u3001\u7528\u6237 ID (UID)\u3001\u7236\u8fdb\u7a0b ID (PPID)\u3001\u8fdb\u7a0b\u72b6\u6001\u3001\u542f\u52a8\u65f6\u95f4\u548c\u547d\u4ee4\u884c\u53c2\u6570\u3002<\/p>\n<p><strong>2. \u4f7f\u7528 top \u547d\u4ee4<\/strong><\/p>\n<p>top \u547d\u4ee4\u63d0\u4f9b\u4e86\u4ea4\u4e92\u5f0f\u8fdb\u7a0b\u76d1\u63a7\u754c\u9762\u3002\u5b83\u663e\u793a\u7cfb\u7edf\u4e2d\u6240\u6709\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\uff0c\u5e76\u6839\u636e CPU \u548c\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u5bf9\u5b83\u4eec\u8fdb\u884c\u6392\u5e8f\u3002<\/p>\n<pre>top<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3. \u4f7f\u7528 pstree \u547d\u4ee4<\/strong><\/p>\n<p>pstree \u547d\u4ee4\u4ee5\u6811\u72b6\u7ed3\u6784\u663e\u793a\u8fdb\u7a0b\u5c42\u6b21\u7ed3\u6784\u3002\u8fd9\u4f7f\u5f97\u53ef\u89c6\u5316\u8fdb\u7a0b\u4e4b\u95f4\u7684\u5173\u7cfb\u53d8\u5f97\u5bb9\u6613\u3002<\/p>\n<pre>pstree<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>4. \u4f7f\u7528 proc \u6587\u4ef6\u7cfb\u7edf<\/strong><\/p>\n<p>proc \u6587\u4ef6\u7cfb\u7edf\u5305\u542b\u4e0e\u7cfb\u7edf\u4e2d\u6bcf\u4e2a\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\u76f8\u5173\u7684\u4fe1\u606f\u3002\u53ef\u4ee5\u67e5\u770b\u6bcf\u4e2a\u8fdb\u7a0b\u7684 \/proc\/[PID] \u76ee\u5f55\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u8981\u67e5\u770b\u8fdb\u7a0b PID \u4e3a 12345 \u7684\u72b6\u6001\uff0c\u53ef\u4ee5\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>cat \/proc\/12345\/status<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u8fdb\u7a0b\u72b6\u6001<\/strong><\/p>\n<p>Linux \u8fdb\u7a0b\u53ef\u4ee5\u5904\u4e8e\u4ee5\u4e0b\u72b6\u6001\u4e4b\u4e00\uff1a<\/p>\n<ul>\n<li> <strong>R:<\/strong> \u8fd0\u884c<\/li>\n<li> <strong>S:<\/strong> \u7761\u7720<\/li>\n<li> <strong>D:<\/strong> \u4e0d\u53ef\u4e2d\u65ad\u7761\u7720<\/li>\n<li> <strong>T:<\/strong> \u5df2\u505c\u6b62<\/li>\n<li> <strong>Z:<\/strong> \u50f5\u5c38\u8fdb\u7a0b<\/li>\n<\/ul>\n<p>\u901a\u8fc7\u4f7f\u7528\u4e0a\u8ff0\u65b9\u6cd5\uff0c\u60a8\u53ef\u4ee5\u8f7b\u677e\u76d1\u63a7 Linux \u7cfb\u7edf\u4e2d\u8fdb\u7a0b\u7684\u72b6\u6001\uff0c\u4ece\u800c\u786e\u4fdd\u7cfb\u7edf\u5e73\u7a33\u8fd0\u884c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\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>\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 ps \u547d\u4ee4\u3001top \u547d\u4ee4\u3001pstree \u547d\u4ee4\u6216 proc \u6587\u4ef6\u7cfb\u7edf\u6765\u67e5\u770b linux \u8fdb\u7a0b\u72b6\u6001\u3002\u8fd9\u6709\u52a9\u4e8e\u76d1\u63a7\u8fdb\u7a0b\u6d3b\u52a8\u548c\u786e\u4fdd\u7cfb\u7edf\u5e73\u7a33\u8fd0\u884c\u3002 \u5982\u4f55\u67e5\u770b Linux \u8fdb\u7a0b\u72b6\u6001 \u5728 Linux \u7cfb\u7edf\u4e2d\uff0c\u67e5\u770b\u8fdb\u7a0b\u72b6\u6001\u81f3\u5173\u91cd\u8981\uff0c\u56e0\u4e3a\u5b83\u5141\u8bb8\u7cfb\u7edf\u7ba1\u7406\u5458\u548c\u7528\u6237\u76d1\u63a7\u7cfb\u7edf\u8fd0\u884c\u4e2d\u8fdb\u7a0b\u7684\u6d3b\u52a8\u3002\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u6cd5\u67e5\u770b\u8fdb\u7a0b\u72b6\u6001\u3002 1. \u4f7f\u7528 ps \u547d\u4ee4 ps \u547d\u4ee4\u662f\u6700\u5e38\u7528\u7684\u67e5\u770b\u8fdb\u7a0b\u72b6\u6001\u7684\u65b9\u6cd5\u3002\u5b83\u53ef\u4ee5\u663e\u793a\u7cfb\u7edf\u4e2d\u6240\u6709\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\u7684\u4fe1\u606f\u3002 ps -ef \u767b\u5f55\u540e\u590d\u5236 \u6b64\u547d\u4ee4\u5c06\u663e\u793a\u6bcf\u4e2a\u8fdb\u7a0b\u7684\u8fdb\u7a0b ID (PID)\u3001\u7528\u6237 ID (UID)\u3001\u7236\u8fdb\u7a0b ID (PPID)\u3001\u8fdb\u7a0b\u72b6\u6001\u3001\u542f\u52a8\u65f6\u95f4\u548c\u547d\u4ee4\u884c\u53c2\u6570\u3002 2. \u4f7f\u7528 top \u547d\u4ee4 top \u547d\u4ee4\u63d0\u4f9b\u4e86\u4ea4\u4e92\u5f0f\u8fdb\u7a0b\u76d1\u63a7\u754c\u9762\u3002\u5b83\u663e\u793a\u7cfb\u7edf\u4e2d\u6240\u6709\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\uff0c\u5e76\u6839\u636e CPU \u548c\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u5bf9\u5b83\u4eec\u8fdb\u884c\u6392\u5e8f\u3002 top \u767b\u5f55\u540e\u590d\u5236 3. \u4f7f\u7528 pstree \u547d\u4ee4 pstree \u547d\u4ee4\u4ee5\u6811\u72b6\u7ed3\u6784\u663e\u793a\u8fdb\u7a0b\u5c42\u6b21\u7ed3\u6784\u3002\u8fd9\u4f7f\u5f97\u53ef\u89c6\u5316\u8fdb\u7a0b\u4e4b\u95f4\u7684\u5173\u7cfb\u53d8\u5f97\u5bb9\u6613\u3002 pstree \u767b\u5f55\u540e\u590d\u5236 4. \u4f7f\u7528 proc \u6587\u4ef6\u7cfb\u7edf proc \u6587\u4ef6\u7cfb\u7edf\u5305\u542b\u4e0e\u7cfb\u7edf\u4e2d\u6bcf\u4e2a\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\u76f8\u5173\u7684\u4fe1\u606f\u3002\u53ef\u4ee5\u67e5\u770b\u6bcf\u4e2a\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-18406","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18406","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=18406"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18406\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=18406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=18406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=18406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}