{"id":278638,"date":"2023-07-25T20:09:45","date_gmt":"2023-07-25T12:09:45","guid":{"rendered":"https:\/\/lrxjmw.cn\/lmlqshqjcm.html"},"modified":"2023-07-25T20:09:45","modified_gmt":"2023-07-25T12:09:45","slug":"lmlqshqjcm","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/lmlqshqjcm.html","title":{"rendered":"Linux\u547d\u4ee4\u8f7b\u677e\u83b7\u53d6\u8fdb\u7a0b\u540d"},"content":{"rendered":"

Linux<\/a>\u662f\u4e00\u6b3e\u5f00\u6e90\u7684\u64cd\u4f5c\u7cfb\u7edf<\/a>\uff0c\u88ab\u5e7f\u6cdb\u5e94\u7528\u4e8e\u670d\u52a1\u5668\u7aef\u548c\u5d4c\u5165\u5f0f\u8bbe\u5907\u3002\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u83b7\u53d6\u8fdb\u7a0b\u540d\u662f\u4e00\u9879\u5e38\u89c1\u7684\u64cd\u4f5c\u3002\u4e0b\u9762\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Linux\u547d\u4ee4<\/a>\u83b7\u53d6\u8fdb\u7a0b\u540d\uff0c\u5e76\u7ed9\u51fa\u4e00\u4e9b\u5b9e\u9645\u6848\u4f8b\u3002<\/p>\n

1.\u4f7f\u7528ps\u547d\u4ee4<\/p>\n

\u901a\u8fc7ps\u547d\u4ee4\uff0c\u53ef\u4ee5\u67e5\u770b\u5f53\u524d\u7cfb\u7edf\u4e2d\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\u4fe1\u606f\u3002\u8981\u83b7\u53d6\u8fdb\u7a0b\u540d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

\n

\nps -eo comm\n<\/pre>\n<\/p>\n

\u8be5\u547d\u4ee4\u4f1a\u5217\u51fa\u6240\u6709\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\u7684\u540d\u79f0\u3002\u53ef\u4ee5\u6839\u636e\u9700\u8981\u8fdb\u884c\u8fdb\u4e00\u6b65\u7b5b\u9009\u548c\u5904\u7406\u3002<\/p>\n

2.\u4f7f\u7528pgrep\u547d\u4ee4<\/p>\n

pgrep\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5de5\u5177linux\u67e5\u770b\u78c1\u76d8\u7a7a\u95f4\uff0c\u53ef\u4ee5\u6839\u636e\u8fdb\u7a0b\u540d\u6216\u5176\u4ed6\u6761\u4ef6\u67e5\u627e\u5339\u914d\u7684\u8fdb\u7a0bID\u3002\u8981\u83b7\u53d6\u8fdb\u7a0b\u540d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

\n

\npgrep -l<process_name>\n<\/pre>\n<\/p>\n

\u5176\u4e2d\u662f\u8981\u67e5\u627e\u7684\u8fdb\u7a0b\u540d\u5173\u952e\u5b57\u3002\u8be5\u547d\u4ee4\u4f1a\u5217\u51fa\u6240\u6709\u5339\u914d\u7684\u8fdb\u7a0bID\u53ca\u5176\u5bf9\u5e94\u7684\u8fdb\u7a0b\u540d\u3002<\/p>\n

3.\u4f7f\u7528\/proc\u6587\u4ef6\u7cfb\u7edf<\/p>\n

\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u6bcf\u4e2a\u8fd0\u884c\u4e2d\u7684\u8fdb\u7a0b\u90fd\u6709\u4e00\u4e2a\u5bf9\u5e94\u7684\u76ee\u5f55\uff0c\u5728\/proc\u76ee\u5f55\u4e0b\u4ee5\u6570\u5b57\u5f62\u5f0f\u5b58\u5728\u3002\u8981\u83b7\u53d6\u67d0\u4e2a\u7279\u5b9a\u8fdb\u7a0b\u7684\u540d\u79f0\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

\n

\ncat \/proc\/<pid>\/comm\n<\/pre>\n<\/p>\n

\u83b7\u53d6\u8fdb\u7a0b\u540d\u79f0_linux \u83b7\u53d6\u8fdb\u7a0b\u540d_linux\u83b7\u53d6\u8fdb\u7a0b\u540d\u79f0<\/p>\n

\u5176\u4e2d\u662f\u8981\u67e5\u8be2\u7684\u8fdb\u7a0bID\u3002\u8be5\u547d\u4ee4\u4f1a\u663e\u793a\u6307\u5b9a\u8fdb\u7a0bID\u5bf9\u5e94\u7684\u8fdb\u7a0b\u540d\u79f0\u3002<\/p>\n

4.\u4f7f\u7528top\u547d\u4ee4<\/p>\n

top\u662f\u4e00\u4e2a\u52a8\u6001\u663e\u793a\u7cfb\u7edf\u8fdb\u7a0b\u4fe1\u606f\u7684\u547d\u4ee4\u884c\u5de5\u5177\u3002\u901a\u8fc7top\u547d\u4ee4\uff0c\u53ef\u4ee5\u67e5\u770b\u5f53\u524d\u7cfb\u7edf\u4e2d\u8fd0\u884c\u7684\u8fdb\u7a0b\u53ca\u5176\u76f8\u5173\u4fe1\u606f\u3002\u8981\u83b7\u53d6\u8fdb\u7a0b\u540d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n

-\u6253\u5f00\u7ec8\u7aef\uff0c\u8f93\u5165top\u547d\u4ee4\uff1b<\/p>\n

-\u6309\u4e0b\u5927\u5199O\u952e\uff08\u5373Shift+O\uff09\uff0c\u7136\u540e\u6309\u4e0b\u5c0f\u5199c\u952e\uff08\u5373c\uff09\uff1b<\/p>\n

-\u8fdb\u7a0b\u5217\u8868\u5c06\u6309\u7167\u8fdb\u7a0b\u540d\u7684\u9996\u5b57\u6bcd\u987a\u5e8f\u6392\u5e8flinux\u624b\u673a\uff0c\u53ef\u4ee5\u901a\u8fc7\u4e0a\u4e0b\u7bad\u5934\u952e\u6d4f\u89c8\u3002<\/p>\n

5.\u4f7f\u7528systemctl\u547d\u4ee4<\/p>\n

\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u57fa\u4e8eSystemd\u7684Linux\u53d1\u884c\u7248\uff08\u5982Ubuntu 16.04\u53ca\u4ee5\u4e0a\u7248\u672c\uff09\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528systemctl\u547d\u4ee4\u83b7\u53d6\u8fdb\u7a0b\u540d\u3002\u8981\u83b7\u53d6\u6b63\u5728\u8fd0\u884c\u7684\u670d\u52a1\u8fdb\u7a0b\u540d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

\n

\nsystemctl list-units --type=service --state=running\n<\/pre>\n<\/p>\n

\u8be5\u547d\u4ee4\u4f1a\u5217\u51fa\u6240\u6709\u6b63\u5728\u8fd0\u884c\u7684\u670d\u52a1\u53ca\u5176\u72b6\u6001\u4fe1\u606f\uff0c\u5305\u62ec\u670d\u52a1\u540d\u79f0\u3002<\/p>\n

6.\u4f7f\u7528pidof\u547d\u4ee4<\/p>\n

pidof\u662f\u4e00\u4e2a\u7b80\u5355\u5b9e\u7528\u7684\u547d\u4ee4\uff0c\u7528\u4e8e\u67e5\u627e\u6307\u5b9a\u8fdb\u7a0b\u540d\u5bf9\u5e94\u7684\u8fdb\u7a0bID\u3002\u8981\u83b7\u53d6\u8fdb\u7a0b\u540d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

linux \u83b7\u53d6\u8fdb\u7a0b\u540d_linux\u83b7\u53d6\u8fdb\u7a0b\u540d\u79f0_\u83b7\u53d6\u8fdb\u7a0b\u540d\u79f0<\/p>\n

\n

\npidof <process_name>\n<\/pre>\n<\/p>\n

\u5176\u4e2d\u662f\u8981\u67e5\u8be2\u7684\u8fdb\u7a0b\u540d\u3002\u8be5\u547d\u4ee4\u4f1a\u8fd4\u56de\u5339\u914d\u7684\u8fdb\u7a0bID\u3002<\/p>\n

7.\u4f7f\u7528grep\u548cps\u547d\u4ee4\u7ec4\u5408<\/p>\n

\u5982\u679c\u4f60\u53ea\u77e5\u9053\u90e8\u5206\u8fdb\u7a0b\u540d\uff0c\u5e76\u4e14\u60f3\u8981\u83b7\u53d6\u5b8c\u6574\u7684\u8fdb\u7a0b\u540dlinux \u83b7\u53d6\u8fdb\u7a0b\u540d<\/strong>\uff0c\u53ef\u4ee5\u4f7f\u7528grep\u548cps\u547d\u4ee4\u7ec4\u5408\u3002\u4f8b\u5982\uff0c\u8981\u83b7\u53d6\u4ee5\"nginx\"\u5f00\u5934\u7684\u6240\u6709\u8fdb\u7a0b\u540d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

\n

\nps -ef | grep "[n]ginx"\n<\/pre>\n<\/p>\n

\u8be5\u547d\u4ee4\u4f1a\u5217\u51fa\u6240\u6709\u5339\u914d\u7684\u8fdb\u7a0b\u4fe1\u606f\u3002<\/p>\n

8.\u4f7f\u7528awk\u547d\u4ee4\u63d0\u53d6\u8fdb\u7a0b\u540d<\/p>\n

\u5982\u679c\u4f60\u60f3\u8981\u8fdb\u4e00\u6b65\u5904\u7406\u548c\u63d0\u53d6\u8fdb\u7a0b\u540d\uff0c\u53ef\u4ee5\u4f7f\u7528awk\u547d\u4ee4\u3002\u4f8b\u5982\uff0c\u8981\u83b7\u53d6\u4ee5\"nginx\"\u5f00\u5934\u7684\u6240\u6709\u8fdb\u7a0b\u540d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

\n

\nps -ef | awk '\/[n]ginx\/{print $NF}'\n<\/pre>\n<\/p>\n

\u8be5\u547d\u4ee4\u4f1a\u53ea\u663e\u793a\u5339\u914d\u7684\u8fdb\u7a0b\u540d\u3002<\/p>\n

\u901a\u8fc7\u4ee5\u4e0a\u65b9\u6cd5linux \u83b7\u53d6\u8fdb\u7a0b\u540d<\/strong>\uff0c\u4f60\u53ef\u4ee5\u65b9\u4fbf\u5730\u5728Linux\u7cfb\u7edf\u4e2d\u83b7\u53d6\u8fdb\u7a0b\u540d\u3002\u65e0\u8bba\u662f\u8c03\u8bd5\u3001\u76d1\u63a7\u8fd8\u662f\u7ba1\u7406\uff0c\u4e86\u89e3\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\u662f\u975e\u5e38\u6709\u7528\u7684\u3002\u5e0c\u671b\u8fd9\u4e9b\u65b9\u6cd5\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"

\u8981\u83b7\u53d6\u8fdb\u7a0b\u540d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a\u8981\u83b7\u53d6\u8fdb\u7a0b\u540d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a04\u53ca\u4ee5\u4e0a\u7248\u672c\uff09\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528systemctl\u547d\u4ee4\u83b7\u53d6\u8fdb\u7a0b\u540d\u3002\u8981\u83b7\u53d6\u6b63\u5728\u8fd0\u884c\u7684\u670d\u52a1\u8fdb\u7a0b\u540d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a\u8981\u83b7\u53d6\u8fdb\u7a0b\u540d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a\u5982\u679c\u4f60\u53ea\u77e5\u9053\u90e8\u5206\u8fdb\u7a0b\u540d\uff0c\u5e76\u4e14\u60f3\u8981\u83b7\u53d6\u5b8c\u6574\u7684\u8fdb\u7a0b\u540d\uff0c\u53ef\u4ee5\u4f7f\u7528grep\u548cps\u547d\u4ee4\u7ec4\u5408\u3002\u4f8b\u5982\uff0c\u8981\u83b7\u53d6\u4ee5nginx\u5f00\u5934\u7684\u6240\u6709\u8fdb\u7a0b\u540d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a\u4f7f\u7528awk\u547d\u4ee4\u63d0\u53d6\u8fdb\u7a0b\u540d\u5982\u679c\u4f60\u60f3\u8981\u8fdb\u4e00\u6b65\u5904\u7406\u548c\u63d0\u53d6\u8fdb\u7a0b\u540d\uff0c\u53ef\u4ee5\u4f7f\u7528awk\u547d\u4ee4\u3002\u4f8b\u5982\uff0c\u8981\u83b7\u53d6\u4ee5nginx\u5f00\u5934\u7684\u6240\u6709\u8fdb\u7a0b\u540d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n","protected":false},"author":1,"featured_media":278639,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[988],"tags":[999],"class_list":["post-278638","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tougao","tag-999"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/278638","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=278638"}],"version-history":[{"count":0,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/278638\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/278639"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=278638"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=278638"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=278638"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}