{"id":18395,"date":"2024-11-18T10:22:34","date_gmt":"2024-11-18T02:22:34","guid":{"rendered":"https:\/\/fwq.ai\/blog\/18395\/"},"modified":"2024-11-18T10:22:34","modified_gmt":"2024-11-18T02:22:34","slug":"linux%e6%9f%a5%e7%9c%8b%e8%bf%9b%e7%a8%8b%e6%98%af%e5%93%aa%e4%b8%aa%e7%a8%8b%e5%ba%8f%e7%9a%84","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/18395\/","title":{"rendered":"linux\u67e5\u770b\u8fdb\u7a0b\u662f\u54ea\u4e2a\u7a0b\u5e8f\u7684"},"content":{"rendered":"<blockquote><p>\n  \u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 ps\u3001top \u548c pstree \u547d\u4ee4\u67e5\u770b linux \u8fdb\u7a0b\u6240\u5c5e\u7684\u7a0b\u5e8f\u3002\u5177\u4f53\u65b9\u6cd5\u5206\u522b\u4e3a\uff1a\u4f7f\u7528 ps \u547d\u4ee4\u67e5\u770b\u8fdb\u7a0b id\u3001\u547d\u4ee4\u884c\u53c2\u6570\u548c\u547d\u4ee4\u540d\u79f0\uff0c\u5176\u4e2d\u547d\u4ee4\u540d\u79f0\u5373\u4e3a\u6240\u5c5e\u7a0b\u5e8f\u3002\u4f7f\u7528 top \u547d\u4ee4\u8fdb\u5165\u641c\u7d22\u6a21\u5f0f\u540e\u8f93\u5165\u8fdb\u7a0b\u540d\u79f0\u67e5\u627e\uff0c\u9009\u4e2d\u540e\u6309 h \u952e\u67e5\u770b &#8220;command&#8221; \u4e00\u680f\u663e\u793a\u7684\u6240\u5c5e\u7a0b\u5e8f\u3002\u4f7f\u7528 pstree \u547d\u4ee4\u751f\u6210\u8fdb\u7a0b\u6811\u5f62\u7ed3\u6784\uff0c\u5176\u4e2d\u8fdb\u7a0b\u7684\u547d\u4ee4\u540d\u79f0\u663e\u793a\u5728\u62ec\u53f7\u5185\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/17\/2024081719035330464.jpg\" class=\"aligncenter\" title=\"linux\u67e5\u770b\u8fdb\u7a0b\u662f\u54ea\u4e2a\u7a0b\u5e8f\u7684\u63d2\u56fe\" alt=\"linux\u67e5\u770b\u8fdb\u7a0b\u662f\u54ea\u4e2a\u7a0b\u5e8f\u7684\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u67e5\u770b Linux \u8fdb\u7a0b\u6240\u5c5e\u7684\u7a0b\u5e8f<\/strong><\/p>\n<p>\u5728 Linux \u7cfb\u7edf\u4e2d\uff0c\u67e5\u770b\u8fdb\u7a0b\u6240\u5c5e\u7684\u7a0b\u5e8f\u6709\u4ee5\u4e0b\u5e38\u7528\u65b9\u6cd5\uff1a<\/p>\n<p><strong>1. \u4f7f\u7528 ps \u547d\u4ee4<\/strong><\/p>\n<p>ps \u547d\u4ee4\u7684\u57fa\u672c\u8bed\u6cd5\u4e3a\uff1a<\/p>\n<pre>ps -F &lt;\u683c\u5f0f&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d \u4e3a\u8f93\u51fa\u683c\u5f0f\u9009\u9879\uff0c\u5e38\u7528\u7684\u9009\u9879\u6709\uff1a<\/p>\n<ul>\n<li>%a\uff1a\u663e\u793a\u6240\u6709\u8fdb\u7a0b\u4fe1\u606f<\/li>\n<li>%p\uff1a\u663e\u793a\u8fdb\u7a0b ID<\/li>\n<li>%c\uff1a\u663e\u793a\u8fdb\u7a0b\u542f\u52a8\u547d\u4ee4<\/li>\n<\/ul>\n<p>\u8981\u67e5\u770b\u8fdb\u7a0b\u6240\u5c5e\u7684\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>ps -eo pid,args,comm | grep &lt;\u8fdb\u7a0b\u540d\u79f0&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4f8b\u5982\uff0c\u8981\u67e5\u627e\u540d\u4e3a &#8220;firefox&#8221; \u7684\u8fdb\u7a0b\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>ps -eo pid,args,comm | grep firefox<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8f93\u51fa\u7ed3\u679c\u5c06\u663e\u793a\u8fdb\u7a0b ID\u3001\u547d\u4ee4\u884c\u53c2\u6570\u548c\u547d\u4ee4\u540d\u79f0\uff0c\u5176\u4e2d\u547d\u4ee4\u540d\u79f0\u5373\u4e3a\u8fdb\u7a0b\u6240\u5c5e\u7684\u7a0b\u5e8f\u3002<\/p>\n<p><strong>2. \u4f7f\u7528 top \u547d\u4ee4<\/strong><\/p>\n<p>top \u547d\u4ee4\u4ee5\u4ea4\u4e92\u5f0f\u65b9\u5f0f\u663e\u793a\u5b9e\u65f6\u8fdb\u7a0b\u4fe1\u606f\u3002\u8981\u67e5\u770b\u8fdb\u7a0b\u6240\u5c5e\u7684\u7a0b\u5e8f\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>top -c -b<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728 top \u754c\u9762\u4e2d\uff0c\u6309 F \u952e\u8fdb\u5165\u641c\u7d22\u6a21\u5f0f\uff0c\u7136\u540e\u8f93\u5165\u8fdb\u7a0b\u540d\u79f0\u5373\u53ef\u67e5\u627e\u5bf9\u5e94\u8fdb\u7a0b\u3002\u9009\u4e2d\u76ee\u6807\u8fdb\u7a0b\u540e\uff0c\u6309 h \u952e\u67e5\u770b\u76f8\u5173\u4fe1\u606f\uff0c\u5176\u4e2d &#8220;COMMAND&#8221; \u4e00\u680f\u663e\u793a\u8fdb\u7a0b\u6240\u5c5e\u7684\u7a0b\u5e8f\u3002<\/p>\n<p><strong>3. \u4f7f\u7528 pstree \u547d\u4ee4<\/strong><\/p>\n<p>pstree \u547d\u4ee4\u53ef\u4ee5\u751f\u6210\u8fdb\u7a0b\u6811\u5f62\u7ed3\u6784\uff0c\u663e\u793a\u6bcf\u4e2a\u8fdb\u7a0b\u53ca\u5176\u5b50\u8fdb\u7a0b\u7684\u5173\u7cfb\u3002\u8981\u67e5\u770b\u8fdb\u7a0b\u6240\u5c5e\u7684\u7a0b\u5e8f\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>pstree -p<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728\u8f93\u51fa\u7684\u6811\u5f62\u7ed3\u6784\u4e2d\uff0c\u6bcf\u4e2a\u8fdb\u7a0b\u7684\u547d\u4ee4\u540d\u79f0\u90fd\u4f1a\u663e\u793a\u5728\u62ec\u53f7\u5185\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u67e5\u770b\u8fdb\u7a0b\u662f\u54ea\u4e2a\u7a0b\u5e8f\u7684\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\u3001top \u548c pstree \u547d\u4ee4\u67e5\u770b linux \u8fdb\u7a0b\u6240\u5c5e\u7684\u7a0b\u5e8f\u3002\u5177\u4f53\u65b9\u6cd5\u5206\u522b\u4e3a\uff1a\u4f7f\u7528 ps \u547d\u4ee4\u67e5\u770b\u8fdb\u7a0b id\u3001\u547d\u4ee4\u884c\u53c2\u6570\u548c\u547d\u4ee4\u540d\u79f0\uff0c\u5176\u4e2d\u547d\u4ee4\u540d\u79f0\u5373\u4e3a\u6240\u5c5e\u7a0b\u5e8f\u3002\u4f7f\u7528 top \u547d\u4ee4\u8fdb\u5165\u641c\u7d22\u6a21\u5f0f\u540e\u8f93\u5165\u8fdb\u7a0b\u540d\u79f0\u67e5\u627e\uff0c\u9009\u4e2d\u540e\u6309 h \u952e\u67e5\u770b &#8220;command&#8221; \u4e00\u680f\u663e\u793a\u7684\u6240\u5c5e\u7a0b\u5e8f\u3002\u4f7f\u7528 pstree \u547d\u4ee4\u751f\u6210\u8fdb\u7a0b\u6811\u5f62\u7ed3\u6784\uff0c\u5176\u4e2d\u8fdb\u7a0b\u7684\u547d\u4ee4\u540d\u79f0\u663e\u793a\u5728\u62ec\u53f7\u5185\u3002 \u5982\u4f55\u67e5\u770b Linux \u8fdb\u7a0b\u6240\u5c5e\u7684\u7a0b\u5e8f \u5728 Linux \u7cfb\u7edf\u4e2d\uff0c\u67e5\u770b\u8fdb\u7a0b\u6240\u5c5e\u7684\u7a0b\u5e8f\u6709\u4ee5\u4e0b\u5e38\u7528\u65b9\u6cd5\uff1a 1. \u4f7f\u7528 ps \u547d\u4ee4 ps \u547d\u4ee4\u7684\u57fa\u672c\u8bed\u6cd5\u4e3a\uff1a ps -F &lt;\u683c\u5f0f&gt; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d \u4e3a\u8f93\u51fa\u683c\u5f0f\u9009\u9879\uff0c\u5e38\u7528\u7684\u9009\u9879\u6709\uff1a %a\uff1a\u663e\u793a\u6240\u6709\u8fdb\u7a0b\u4fe1\u606f %p\uff1a\u663e\u793a\u8fdb\u7a0b ID %c\uff1a\u663e\u793a\u8fdb\u7a0b\u542f\u52a8\u547d\u4ee4 \u8981\u67e5\u770b\u8fdb\u7a0b\u6240\u5c5e\u7684\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a ps -eo pid,args,comm | grep &lt;\u8fdb\u7a0b\u540d\u79f0&gt; \u767b\u5f55\u540e\u590d\u5236 \u4f8b\u5982\uff0c\u8981\u67e5\u627e\u540d\u4e3a &#8220;firefox&#8221; \u7684\u8fdb\u7a0b\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a ps -eo pid,args,comm | [&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-18395","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18395","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=18395"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18395\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=18395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=18395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=18395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}