{"id":18383,"date":"2024-11-18T11:33:38","date_gmt":"2024-11-18T03:33:38","guid":{"rendered":"https:\/\/fwq.ai\/blog\/18383\/"},"modified":"2024-11-18T11:33:38","modified_gmt":"2024-11-18T03:33:38","slug":"linux%e6%9f%a5%e7%9c%8b%e5%bd%93%e5%89%8d%e8%bf%90%e8%a1%8c%e8%bf%9b%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/18383\/","title":{"rendered":"linux\u67e5\u770b\u5f53\u524d\u8fd0\u884c\u8fdb\u7a0b"},"content":{"rendered":"<blockquote><p>\n  \u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\u67e5\u770b linux \u4e2d\u5f53\u524d\u8fd0\u884c\u7684\u8fdb\u7a0b\uff1a\u4f7f\u7528 &#8220;ps&#8221; \u547d\u4ee4\u6765\u67e5\u770b\u8fdb\u7a0b\u4fe1\u606f\uff0c\u5305\u62ec pid\u3001\u7528\u6237\u3001cpu \u548c\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u3002\u4f7f\u7528 &#8220;top&#8221; \u547d\u4ee4\u63d0\u4f9b\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u754c\u9762\uff0c\u6309 cpu \u6216\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u5bf9\u8fdb\u7a0b\u8fdb\u884c\u6392\u5e8f\u3002\u4f7f\u7528 &#8220;pidof&#8221; \u547d\u4ee4\u901a\u8fc7\u540d\u79f0\u67e5\u627e\u8fdb\u7a0b\u7684 pid\u3002\u4f7f\u7528 &#8220;pgrep&#8221; \u547d\u4ee4\u901a\u8fc7\u6b63\u5219\u8868\u8fbe\u5f0f\u67e5\u627e\u8fdb\u7a0b\u7684 pid\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/17\/2024081718515928126.jpg\" class=\"aligncenter\" title=\"linux\u67e5\u770b\u5f53\u524d\u8fd0\u884c\u8fdb\u7a0b\u63d2\u56fe\" alt=\"linux\u67e5\u770b\u5f53\u524d\u8fd0\u884c\u8fdb\u7a0b\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u67e5\u770b Linux \u4e2d\u5f53\u524d\u8fd0\u884c\u7684\u8fdb\u7a0b\uff1f<\/strong><\/p>\n<p>\u5bf9\u4e8e Linux \u7cfb\u7edf\u7ba1\u7406\u5458\u6765\u8bf4\uff0c\u4e86\u89e3\u548c\u7ba1\u7406\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\u81f3\u5173\u91cd\u8981\u3002\u4ee5\u4e0b\u662f\u67e5\u770b\u5f53\u524d\u8fd0\u884c\u8fdb\u7a0b\u7684\u51e0\u79cd\u65b9\u6cd5\uff1a<\/p>\n<p><strong>1. \u4f7f\u7528\u201cps\u201d\u547d\u4ee4<\/strong><\/p>\n<p>\u201cps\u201d\u547d\u4ee4\u662f\u67e5\u770b\u8fdb\u7a0b\u4fe1\u606f\u7684\u5f3a\u5927\u5de5\u5177\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u57fa\u672c\u547d\u4ee4\uff1a<\/p>\n<pre>ps<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u663e\u793a\u4ee5\u4e0b\u4fe1\u606f\uff1a<\/p>\n<ul>\n<li> <strong>PID<\/strong>\uff1a\u8fdb\u7a0b ID<\/li>\n<li> <strong>USER<\/strong>\uff1a\u8fdb\u7a0b\u6240\u6709\u8005<\/li>\n<li> <strong>%CPU<\/strong>\uff1a\u8fdb\u7a0b\u6d88\u8017\u7684 CPU \u767e\u5206\u6bd4<\/li>\n<li> <strong>%MEM<\/strong>\uff1a\u8fdb\u7a0b\u6d88\u8017\u7684\u5185\u5b58\u767e\u5206\u6bd4<\/li>\n<li> <strong>VSZ<\/strong>\uff1a\u8fdb\u7a0b\u7684\u865a\u62df\u5185\u5b58\u5927\u5c0f<\/li>\n<li> <strong>RSS<\/strong>\uff1a\u8fdb\u7a0b\u7684\u9a7b\u7559\u96c6\u5927\u5c0f<\/li>\n<li> <strong>TTY<\/strong>\uff1a\u8fdb\u7a0b\u8fde\u63a5\u7684\u7ec8\u7aef<\/li>\n<li> <strong>STAT<\/strong>\uff1a\u8fdb\u7a0b\u72b6\u6001\uff08\u5982 S\uff08\u4f11\u7720\uff09\u3001R\uff08\u6b63\u5728\u8fd0\u884c\uff09\uff09<\/li>\n<li> <strong>START<\/strong>\uff1a\u8fdb\u7a0b\u542f\u52a8\u65f6\u95f4<\/li>\n<li> <strong>TIME<\/strong>\uff1a\u8fdb\u7a0b\u8fd0\u884c\u65f6\u95f4<\/li>\n<li> <strong>COMMAND<\/strong>\uff1a\u8fdb\u7a0b\u7684\u547d\u4ee4\u884c<\/li>\n<\/ul>\n<p><strong>2. \u4f7f\u7528\u201ctop\u201d\u547d\u4ee4<\/strong><\/p>\n<p>\u201ctop\u201d\u547d\u4ee4\u63d0\u4f9b\u4e86\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u754c\u9762\u6765\u67e5\u770b\u8fdb\u7a0b\u4fe1\u606f\u3002\u5b83\u6309 CPU \u6216\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u5bf9\u8fdb\u7a0b\u8fdb\u884c\u6392\u5e8f\uff0c\u5e76\u5141\u8bb8\u60a8\u5b9e\u65f6\u76d1\u63a7\u7cfb\u7edf\u3002<\/p>\n<p>\u8981\u4f7f\u7528\u201ctop\u201d\u547d\u4ee4\uff0c\u8bf7\u8f93\u5165\uff1a<\/p>\n<pre>top<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u952e\u5bfc\u822a\u547d\u4ee4\uff1a<\/p>\n<ul>\n<li> <strong>h<\/strong>\uff1a\u663e\u793a\u5e2e\u52a9\u83dc\u5355<\/li>\n<li> <strong>q<\/strong>\uff1a\u9000\u51fa<\/li>\n<li> <strong>s<\/strong>\uff1a\u6309 CPU \u4f7f\u7528\u60c5\u51b5\u6392\u5e8f<\/li>\n<li> <strong>m<\/strong>\uff1a\u6309\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u6392\u5e8f<\/li>\n<\/ul>\n<p><strong>3. \u4f7f\u7528\u201cpidof\u201d\u547d\u4ee4<\/strong><\/p>\n<p>\u201cpidof\u201d\u547d\u4ee4\u5141\u8bb8\u60a8\u901a\u8fc7\u5176\u540d\u79f0\u67e5\u627e\u8fdb\u7a0b\u7684 PID\u3002\u4f8b\u5982\uff0c\u8981\u67e5\u627e\u540d\u4e3a\u201cbash\u201d\u7684\u8fdb\u7a0b\u7684 PID\uff0c\u60a8\u53ef\u4ee5\u8f93\u5165\uff1a<\/p>\n<pre>pidof bash<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u8fd4\u56de\u4ee5\u4e0b\u8f93\u51fa\uff1a<\/p>\n<pre>1234<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d 1234 \u662f bash \u8fdb\u7a0b\u7684 PID\u3002<\/p>\n<p><strong>4. \u4f7f\u7528\u201cpgrep\u201d\u547d\u4ee4<\/strong><\/p>\n<p>\u201cpgrep\u201d\u547d\u4ee4\u4e0e\u201cpidof\u201d\u7c7b\u4f3c\uff0c\u4f46\u5b83\u5141\u8bb8\u60a8\u6307\u5b9a\u4e00\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0f\u6765\u67e5\u627e\u8fdb\u7a0b\u3002\u4f8b\u5982\uff0c\u8981\u67e5\u627e\u540d\u79f0\u4e2d\u5305\u542b\u201cgnome\u201d\u7684\u8fdb\u7a0b\uff0c\u60a8\u53ef\u4ee5\u8f93\u5165\uff1a<\/p>\n<pre>pgrep -f gnome<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u8fd4\u56de\u4ee5\u4e0b\u8f93\u51fa\uff1a<\/p>\n<pre>1234\n2345\n3456<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d 1234\u30012345 \u548c 3456 \u662f\u540d\u79f0\u4e2d\u5305\u542b\u201cgnome\u201d\u7684\u8fdb\u7a0b\u7684 PID\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u67e5\u770b\u5f53\u524d\u8fd0\u884c\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>\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\u67e5\u770b linux \u4e2d\u5f53\u524d\u8fd0\u884c\u7684\u8fdb\u7a0b\uff1a\u4f7f\u7528 &#8220;ps&#8221; \u547d\u4ee4\u6765\u67e5\u770b\u8fdb\u7a0b\u4fe1\u606f\uff0c\u5305\u62ec pid\u3001\u7528\u6237\u3001cpu \u548c\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u3002\u4f7f\u7528 &#8220;top&#8221; \u547d\u4ee4\u63d0\u4f9b\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u754c\u9762\uff0c\u6309 cpu \u6216\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u5bf9\u8fdb\u7a0b\u8fdb\u884c\u6392\u5e8f\u3002\u4f7f\u7528 &#8220;pidof&#8221; \u547d\u4ee4\u901a\u8fc7\u540d\u79f0\u67e5\u627e\u8fdb\u7a0b\u7684 pid\u3002\u4f7f\u7528 &#8220;pgrep&#8221; \u547d\u4ee4\u901a\u8fc7\u6b63\u5219\u8868\u8fbe\u5f0f\u67e5\u627e\u8fdb\u7a0b\u7684 pid\u3002 \u5982\u4f55\u67e5\u770b Linux \u4e2d\u5f53\u524d\u8fd0\u884c\u7684\u8fdb\u7a0b\uff1f \u5bf9\u4e8e Linux \u7cfb\u7edf\u7ba1\u7406\u5458\u6765\u8bf4\uff0c\u4e86\u89e3\u548c\u7ba1\u7406\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\u81f3\u5173\u91cd\u8981\u3002\u4ee5\u4e0b\u662f\u67e5\u770b\u5f53\u524d\u8fd0\u884c\u8fdb\u7a0b\u7684\u51e0\u79cd\u65b9\u6cd5\uff1a 1. \u4f7f\u7528\u201cps\u201d\u547d\u4ee4 \u201cps\u201d\u547d\u4ee4\u662f\u67e5\u770b\u8fdb\u7a0b\u4fe1\u606f\u7684\u5f3a\u5927\u5de5\u5177\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u57fa\u672c\u547d\u4ee4\uff1a ps \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u5c06\u663e\u793a\u4ee5\u4e0b\u4fe1\u606f\uff1a PID\uff1a\u8fdb\u7a0b ID USER\uff1a\u8fdb\u7a0b\u6240\u6709\u8005 %CPU\uff1a\u8fdb\u7a0b\u6d88\u8017\u7684 CPU \u767e\u5206\u6bd4 %MEM\uff1a\u8fdb\u7a0b\u6d88\u8017\u7684\u5185\u5b58\u767e\u5206\u6bd4 VSZ\uff1a\u8fdb\u7a0b\u7684\u865a\u62df\u5185\u5b58\u5927\u5c0f RSS\uff1a\u8fdb\u7a0b\u7684\u9a7b\u7559\u96c6\u5927\u5c0f TTY\uff1a\u8fdb\u7a0b\u8fde\u63a5\u7684\u7ec8\u7aef STAT\uff1a\u8fdb\u7a0b\u72b6\u6001\uff08\u5982 S\uff08\u4f11\u7720\uff09\u3001R\uff08\u6b63\u5728\u8fd0\u884c\uff09\uff09 START\uff1a\u8fdb\u7a0b\u542f\u52a8\u65f6\u95f4 TIME\uff1a\u8fdb\u7a0b\u8fd0\u884c\u65f6\u95f4 COMMAND\uff1a\u8fdb\u7a0b\u7684\u547d\u4ee4\u884c 2. \u4f7f\u7528\u201ctop\u201d\u547d\u4ee4 \u201ctop\u201d\u547d\u4ee4\u63d0\u4f9b\u4e86\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u754c\u9762\u6765\u67e5\u770b\u8fdb\u7a0b\u4fe1\u606f\u3002\u5b83\u6309 CPU \u6216\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u5bf9\u8fdb\u7a0b\u8fdb\u884c\u6392\u5e8f\uff0c\u5e76\u5141\u8bb8\u60a8\u5b9e\u65f6\u76d1\u63a7\u7cfb\u7edf\u3002 \u8981\u4f7f\u7528\u201ctop\u201d\u547d\u4ee4\uff0c\u8bf7\u8f93\u5165\uff1a top \u767b\u5f55\u540e\u590d\u5236 \u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u952e\u5bfc\u822a\u547d\u4ee4\uff1a h\uff1a\u663e\u793a\u5e2e\u52a9\u83dc\u5355 q\uff1a\u9000\u51fa [&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-18383","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18383","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=18383"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18383\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=18383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=18383"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=18383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}