{"id":257006,"date":"2022-12-05T09:32:33","date_gmt":"2022-12-05T01:32:33","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=257006"},"modified":"2022-11-07T08:33:43","modified_gmt":"2022-11-07T00:33:43","slug":"linux-uptime","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-uptime.html","title":{"rendered":"Linux \u670d\u52a1\u5668\u7684\u8fd0\u884c\u65f6\u95f4\u68c0\u67e5\u6280\u5de7"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u6709\u4e00\u70b9\u9700\u8981\u6ce8\u610f\uff0c\u4f7f\u7528uprecords\u4e0d\u4f1a\u9a6c\u4e0a\u5c31\u83b7\u5f97\u5386\u53f2\u8fd0\u884c\u7684\u65f6\u95f4\u8bb0\u5f55\uff0c\u5b83\u662f\u4ece\u5b89\u88c5 uptimed \u4e4b\u540e\u5f00\u59cb\u8bb0\u5f55\u7684\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

Linux \u4e2d\u7684 uptime \u7528\u4e8e\u67e5\u770b\u7cfb\u7edf\u542f\u52a8\u540e\u7684\u8fd0\u884c\u65f6\u95f4\u3002\u5b83\u662f\u4e00\u4e2a\u6bd4\u8f83\u7b80\u5355\u7684 Linux \u547d\u4ee4\uff0c\u53ef\u4ee5\u4e0d\u5e26\u53c2\u6570\u76f4\u63a5\u8fd0\u884c\uff1a<\/p>\n

uptime<\/pre>\n

\u8fd9\u5c06\u663e\u793a\u4e00\u884c\u8f93\u51fa\uff0c\u663e\u793a\u5f53\u524d\u65f6\u95f4\u3001\u6b63\u5e38\u8fd0\u884c\u65f6\u95f4\uff08\u4ee5\u5929\u548c\u5c0f\u65f6\u4e3a\u5355\u4f4d\uff09\u3001\u5f53\u524d\u767b\u5f55\u5230\u7cfb\u7edf\u7684\u7528\u6237\u6570\u548c\u5e73\u5747\u8d1f\u8f7d\u3002<\/p>\n

\u4ee5\u4e0b\u662f uptime \u547d\u4ee4\u7684\u793a\u4f8b\u8f93\u51fa\uff1a<\/p>\n

[gliu@fedora ~]$ uptime\r\n21:11:43 up 5:32, 1 user, load average: 0.15, 0.09, 0.07<\/pre>\n

\u901a\u8fc7\u4e0a\u8ff0\u8f93\u51fa\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u770b\u5230\u7cfb\u7edf\u7684\u8fd0\u884c\u4fe1\u606f\u3002\u5404\u8f93\u51fa\u5143\u7d20\u89e3\u91ca\u5982\u4e0b\uff1a<\/p>\n

    \n
  • 21:11:43 - \u7cfb\u7edf\u7684\u5f53\u524d\u65f6\u95f4\uff1b<\/li>\n
  • up \u00a05:32 - \u8fd9\u8868\u793aLinux\u7cfb\u7edf\u5df2\u7ecf\u8fd0\u884c\u4e865\u5c0f\u65f632\u5206\u949f\uff1b<\/li>\n
  • 1 user - \u8fd9\u662f\u5f53\u524d\u767b\u5f55\u5230Linux\u7cfb\u7edf\u7684\u7528\u6237\u6570\uff1b<\/li>\n
  • load average: 0.15, 0.09, 0.07 - \u8fd9\u7ed9\u51fa\u4e86\u8fc7\u53bb1\u30015\u548c15\u5206\u949f\u7684\u5e73\u5747CPU\u8d1f\u8f7d\u30020.15\u610f\u5473\u774015%\u7684CPU\u6d88\u8017\uff08\u5982\u679c\u662f4\u6838CPU\uff0c\u5219\u610f\u5473\u77404\u4e2a\u6838\u4e2d\u67090.15\u4e2a\u5728\u4f7f\u7528\uff09\u3002<\/li>\n<\/ul>\n

    \u4e0e\u5176\u4ed6\u5927\u591a\u6570\u547d\u4ee4\u4e00\u6837\uff0cuptime \u547d\u4ee4\u4ece \/proc \u6587\u4ef6\u4e2d\u83b7\u53d6\u7cfb\u7edf\u542f\u52a8\u7684\u76f8\u5173\u4fe1\u606f\uff0c\u4ece \/var\/run\/utmp \u6587\u4ef6\u4e2d\u83b7\u53d6\u767b\u5f55\u7528\u6237\u7684\u4fe1\u606f\u3002<\/p>\n

    uptime \u6709\u4e00\u4e9b\u53ef\u9009\u7684\u53c2\u6570\uff0c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\u4f1a\u975e\u5e38\u6709\u7528\u3002<\/p>\n

    \u4f7f\u7528\u5e26\u53c2\u6570\u7684 uptime \u547d\u4ee4<\/strong><\/div>\n

    \u5982\u679c\u4f60\u89c9\u5f97 uptime \u7684\u8f93\u51fa\u6bd4\u8f83\u6742\u4e71\uff0c\u53ef\u4ee5\u4f7f\u7528 -p \u9009\u9879\u6765\u8ba9\u8f93\u51fa\u66f4\u6613\u8bfb\u4e00\u4e9b\uff1a<\/p>\n

    uptime -p<\/pre>\n

    \u8fd9\u6837\u5c31\u53ea\u4f1a\u663e\u793a\u7cfb\u7edf\u8fd0\u884c\u7684\u65f6\u95f4\uff0c\u4e5f\u662f\u4ee5\u6587\u672c\u7684\u5f62\u5f0f\uff0c\u4f46\u662f\u66f4\u6613\u8bfb\uff1a<\/p>\n

    [gliu@fedora ~]$ uptime -p\r\nup 5 hours, 32 minutes<\/pre>\n

    \u5982\u679c\u60f3\u8981\u67e5\u770b\u7cfb\u7edf\u662f\u4ece\u4ec0\u4e48\u65f6\u5019\u5f00\u59cb\u8fd0\u884c\u7684\uff0c\u53ef\u4ee5\u4f7f\u7528 -s \u9009\u9879\uff1a<\/p>\n

    uptime -s<\/pre>\n

    \u8fd9\u5c06\u663e\u793a\u7cfb\u7edf\u542f\u52a8\u65f6\u7684\u786e\u5207\u65f6\u95f4\uff1a<\/p>\n

    [gliu@fedora ~]$ uptime -s\r\n2022-07-12 15:39:33<\/pre>\n

    \"\"<\/p>\n

    \u6b64\u5916\uff0c\u8fd8\u6709\u4e00\u4e9b\u5176\u4ed6\u7684\u9009\u9879\uff0c\u6bd4\u5982 -V \u663e\u793a\u547d\u4ee4\u7684\u7248\u672c\uff0c-h \u663e\u793a\u5e2e\u52a9\u4fe1\u606f\u3002<\/p>\n

    \u6ce8\uff1auptime \u547d\u4ee4\u7684\u9ed8\u8ba4\u8f93\u51fa\u663e\u793a\u4e0e w \u547d\u4ee4\u7b2c\u4e00\u884c\u4e2d\u83b7\u5f97\u7684\u4fe1\u606f\u76f8\u540c\u3002<\/p>\n

    \u8bb0\u5f55\u4f60\u7684\u8fd0\u884c\u65f6\u95f4<\/strong><\/div>\n

    uptime\u547d\u4ee4\u4ec5\u663e\u793a\u7cfb\u7edf\u5df2\u8fd0\u884c\u7684\u65f6\u95f4\u3002\u6709\u4e00\u4e2a\u5f88\u65b9\u4fbf\u7684\u5de5\u5177\u53eb\u505a uprecords\uff0c\u53ef\u4ee5\u8bb0\u5f55\u4f60\u7684\u8fd0\u884c\u65f6\u95f4\u3002<\/p>\n

    \u5b83\u4ee5\u8868\u683c\u5f62\u5f0f\u663e\u793a\u4e86Linux\u7cfb\u7edf\u7684\u6700\u957f\u8fd0\u884c\u65f6\u95f4\uff0c\u4ee5\u53ca\u5176\u4ed6\u6709\u5173\u542f\u52a8\u65f6\u95f4\u3001\u6301\u7eed\u65f6\u95f4\u548cLinux\u5185\u6838\u7248\u672c\u7b49\u7684\u4fe1\u606f\u3002<\/p>\n

    \"\"<\/p>\n

    \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cuprecords \u662f\u6ca1\u6709\u5b89\u88c5\u7684\uff0c\u5b83\u5305\u542b\u5728uptimed\u5305\u4e2d\uff0c\u4f60\u9700\u8981\u624b\u52a8\u5b89\u88c5\u3002\u5728Debian\u6216\u8005Ubuntu\u4e0a\uff0c\u53ef\u4ee5\u8fd9\u6837\u5b89\u88c5\uff1a<\/p>\n

    sudo apt install uptimed<\/pre>\n

    \u5b83\u57fa\u672c\u4e0a\u662f\u4e00\u4e2a\u5b88\u62a4\u8fdb\u7a0b\uff0c\u901a\u8fc7\u5f15\u5bfcID\u8ddf\u8e2a\u7cfb\u7edf\u8fd0\u884c\u65f6\u95f4\uff0c\u4f7f\u7528\u7cfb\u7edf\u5f15\u5bfc\u65f6\u95f4\u4f7f\u4f1a\u8bdd\u5f7c\u6b64\u5206\u79bb\u3002<\/p>\n

    \u5b89\u88c5\u5b8c uptimed\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528 uprecords \u547d\u4ee4\u6765\u663e\u793a\u8fd0\u884c\u65f6\u95f4\u8bb0\u5f55\u4e86\uff1a<\/p>\n

    uprecords<\/pre>\n

    \u6709\u4e00\u70b9\u9700\u8981\u6ce8\u610f\uff0c\u4f7f\u7528uprecords\u4e0d\u4f1a\u9a6c\u4e0a\u5c31\u83b7\u5f97\u5386\u53f2\u8fd0\u884c\u7684\u65f6\u95f4\u8bb0\u5f55\uff0c\u5b83\u662f\u4ece\u5b89\u88c5 uptimed \u4e4b\u540e\u5f00\u59cb\u8bb0\u5f55\u7684\u3002<\/p>\n

    \u4ee5\u4e0a\u662f\u672c\u6b21\u5206\u4eab\u5168\u90e8\u5185\u5bb9\uff0c\u4f60\u4e0a\u6b21\u91cd\u542fLinux\u670d\u52a1\u5668\u662f\u4ec0\u4e48\u65f6\u5019\u5462\uff1f\u6b22\u8fce\u8ba8\u8bba\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

    Linux \u4e2d\u7684 uptime \u7528\u4e8e\u67e5\u770b\u7cfb\u7edf\u542f\u52a8\u540e\u7684\u8fd0\u884c\u65f6\u95f4\u3002\u5b83\u662f\u4e00\u4e2a\u6bd4\u8f83\u7b80\u5355\u7684 Linux \u547d\u4ee4\uff0c\u53ef\u4ee5\u4e0d\u5e26\u53c2 […]<\/p>\n","protected":false},"author":323,"featured_media":254376,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-257006","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/257006","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\/323"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=257006"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/257006\/revisions"}],"predecessor-version":[{"id":257015,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/257006\/revisions\/257015"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/254376"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=257006"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=257006"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=257006"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}