{"id":259207,"date":"2023-01-11T08:37:29","date_gmt":"2023-01-11T00:37:29","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=259207"},"modified":"2022-12-24T12:22:00","modified_gmt":"2022-12-24T04:22:00","slug":"shut-down-linux","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/shut-down-linux.html","title":{"rendered":"\u7b80\u5355\u8bf4\u8bf4linux\u5173\u673a\u547d\u4ee4"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nLiux\u662f\u4e00\u5957\u514d\u8d39\u4f7f\u7528\u548c\u81ea\u7531\u4f20\u64ad\u7684\u7c7bUix\u64cd\u4f5c\u7cfb\u7edf\uff0c\u662f\u4e00\u4e2a\u57fa\u4e8ePOSIX\u548cUNIX\u7684\u591a\u7528\u6237\u3001\u591a\u4efb\u52a1\u3001\u652f\u6301\u591a\u7ebf\u7a0b\u548c\u591aCPU\u7684\u64cd\u4f5c\u7cfb\u7edf\u3002\u90a3\u4e48linux\u5173\u673a\u547d\u4ee4\u662f\u4ec0\u4e48?\u4e0b\u9762\u4e3a\u5927\u5bb6\u4ecb\u7ecd\u4e0blinux\u5173\u673a\u547d\u4ee4\uff0c\u8d76\u7d27\u770b\u770b\u5427\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u5728linux\u4e0b\u4e00\u4e9b\u5e38\u7528\u7684\u5173\u673a\/\u91cd\u542f\u547d\u4ee4\u6709shutdown\u3001halt\u3001reboot\u3001\u53cainit\uff0c\u5b83\u4eec\u90fd\u53ef\u4ee5\u8fbe\u5230\u91cd\u542f\u7cfb\u7edf\u7684\u76ee\u7684\uff0c\u4f46\u6bcf\u4e2a\u547d\u4ee4\u7684\u5185\u90e8\u5de5\u4f5c\u8fc7\u7a0b\u662f\u4e0d\u540c\u7684\u3002<\/p>\n

\"\"<\/p>\n

Linux centos\u91cd\u542f\u547d\u4ee4\uff1a<\/strong><\/div>\n
1\u3001reboot<\/pre>\n
2\u3001shutdown -r now # \u7acb\u523b\u91cd\u542f(root\u7528\u6237\u4f7f\u7528)<\/pre>\n
3\u3001shutdown -r 10 # \u8fc710\u5206\u949f\u81ea\u52a8\u91cd\u542f(root\u7528\u6237\u4f7f\u7528)<\/pre>\n
4\u3001shutdown -r 20:35  # \u5728\u65f6\u95f4\u4e3a20:35\u65f6\u5019\u91cd\u542f(root\u7528\u6237\u4f7f\u7528)<\/pre>\n

\u5982\u679c\u662f\u901a\u8fc7shutdown\u547d\u4ee4\u8bbe\u7f6e\u91cd\u542f\u7684\u8bdd\uff0c\u53ef\u4ee5\u7528shutdown -c\u547d\u4ee4\u53d6\u6d88\u91cd\u542f\u3002<\/p>\n

Linux centos\u5173\u673a\u547d\u4ee4\uff1a<\/strong><\/div>\n
1\u3001halt #\u7acb\u523b\u5173\u673a<\/pre>\n
2\u3001poweroff #\u7acb\u523b\u5173\u673a<\/pre>\n
3\u3001shutdown -h now #\u7acb\u523b\u5173\u673a(root\u7528\u6237\u4f7f\u7528)\u3002<\/pre>\n
4\u3001shutdown -h 10 #10\u5206\u949f\u540e\u81ea\u52a8\u5173\u673a\u3002<\/pre>\n

\u5982\u679c\u662f\u901a\u8fc7shutdown\u547d\u4ee4\u8bbe\u7f6e\u5173\u673a\u7684\u8bdd\uff0c\u53ef\u4ee5\u7528shutdown -c\u547d\u4ee4\u53d6\u6d88\u91cd\u542f\u3002<\/p>\n

1\u3001shutdown<\/strong><\/span><\/div>\n

shutdown\u547d\u4ee4\u5b89\u5168\u5730\u5c06\u7cfb\u7edf\u5173\u673a\u3002\u6709\u4e9b\u7528\u6237\u4f1a\u4f7f\u7528\u76f4\u63a5\u65ad\u6389\u7535\u6e90\u7684\u65b9\u5f0f\u6765\u5173\u95edlinux\uff0c\u8fd9\u662f\u5341\u5206\u5371\u9669\u7684\u3002\u56e0\u4e3alinux\u4e0ewindows\u4e0d\u540c\uff0c\u5176\u540e\u53f0\u8fd0\u884c\u7740\u8bb8\u591a\u8fdb\u7a0b\uff0c\u6240\u4ee5\u5f3a\u5236\u5173\u673a\u53ef\u80fd\u4f1a\u5bfc\u81f4\u8fdb\u7a0b\u7684\u6570\u636e\u4e22\u5931\uff0c\u4f7f\u7cfb\u7edf\u5904\u4e8e\u4e0d\u7a33\u5b9a\u7684\u72b6\u6001\uff0c\u751a\u81f3\u5728\u6709\u7684\u7cfb\u7edf\u4e2d\u4f1a\u635f\u574f\u786c\u4ef6\u8bbe\u5907\u3002<\/p>\n

\u800c\u5728\u7cfb\u7edf\u5173\u673a\u524d\u4f7f\u7528shutdown\u547d\u4ee4\uff0c\u7cfb\u7edf\u7ba1\u7406\u5458\u4f1a\u901a\u77e5\u6240\u6709\u767b\u5f55\u7684\u7528\u6237\u7cfb\u7edf\u5c06\u8981\u5173\u95ed\u3002\u5e76\u4e14login\u6307\u4ee4\u4f1a\u88ab\u51bb\u7ed3\uff0c\u5373\u65b0\u7684\u7528\u6237\u4e0d\u80fd\u518d\u767b\u5f55\u3002\u76f4\u63a5\u5173\u673a\u6216\u8005\u5ef6\u8fdf\u4e00\u5b9a\u7684\u65f6\u95f4\u624d\u5173\u673a\u90fd\u662f\u53ef\u80fd\u7684\uff0c\u8fd8\u53ef\u80fd\u91cd\u542f\u3002\u8fd9\u662f\u7531\u6240\u6709\u8fdb\u7a0b(process)\u90fd\u4f1a\u6536\u5230\u7cfb\u7edf\u6240\u9001\u8fbe\u7684\u4fe1\u53f7(signal)\u51b3\u5b9a\u7684\u3002\u8fd9\u8ba9\u50cfvi\u4e4b\u7c7b\u7684\u7a0b\u5e8f\u6709\u65f6\u95f4\u50a8\u5b58\u76ee\u524d\u6b63\u5728\u7f16\u8f91\u7684\u6587\u6863\uff0c\u800c\u50cf\u5904\u7406\u90ae\u4ef6(mail)\u548c\u65b0\u95fb(news)\u7684\u7a0b\u5e8f\u5219\u53ef\u4ee5\u6b63\u5e38\u5730\u79bb\u5f00\u7b49\u7b49\u3002<\/p>\n

shutdown\u6267\u884c\u5b83\u7684\u5de5\u4f5c\u662f\u9001\u4fe1\u53f7(signal)\u7ed9init\u7a0b\u5e8f\uff0c\u8981\u6c42\u5b83\u6539\u53d8runlevel\u3002Runlevel 0\u88ab\u7528\u6765\u505c\u673a(halt)\uff0crunlevel 6\u662f\u7528\u6765\u91cd\u65b0\u6fc0\u6d3b(reboot)\u7cfb\u7edf\uff0c\u800crunlevel 1\u5219\u662f\u88ab\u7528\u6765\u8ba9\u7cfb\u7edf\u8fdb\u5165\u7ba1\u7406\u5de5\u4f5c\u53ef\u4ee5\u8fdb\u884c\u7684\u72b6\u6001\u3002\u8fd9\u662f\u9884\u8bbe\u7684\uff0c\u5047\u5b9a\u6ca1\u6709-h\u4e5f\u6ca1\u6709-r\u53c2\u6570\u7ed9shutdown\u3002\u8981\u60f3\u4e86\u89e3\u5728\u505c\u673a(halt)\u6216\u8005\u91cd\u65b0\u5f00\u673a(reboot)\u8fc7\u7a0b\u4e2d\u505a\u4e86\u54ea\u4e9b\u52a8\u4f5c\uff0c\u53ef\u4ee5\u5728\u8fd9\u4e2a\u6587\u4ef6\/etc\/inittab\u91cc\u770b\u5230\u8fd9\u4e9brunlevels\u76f8\u5173\u7684\u8d44\u6599\u3002<\/p>\n

\"\"<\/p>\n

shutdown \u53c2\u6570\u8bf4\u660e\uff1a<\/strong><\/span><\/div>\n
  • [-t] \u5728\u6539\u53d8\u5230\u5176\u5b83runlevel\u4e4b\u524d\uff0c\u544a\u8bc9init\u591a\u4e45\u4ee5\u540e\u5173\u673a\u3002<\/li>\n

    \u3000\u3000<\/p>\n

  • [-r] \u91cd\u542f\u8ba1\u7b97\u5668\u3002<\/li>\n

    \u3000\u3000<\/p>\n

  • [-k] \u5e76\u4e0d\u771f\u6b63\u5173\u673a\uff0c\u53ea\u662f\u9001\u8b66\u544a\u4fe1\u53f7\u7ed9\u6bcf\u4f4d\u767b\u5f55\u8005(login)\u3002<\/li>\n

    \u3000\u3000<\/p>\n

  • [-h] \u5173\u673a\u540e\u5173\u95ed\u7535\u6e90(halt)\u3002<\/li>\n

    \u3000\u3000<\/p>\n

  • [-n] \u4e0d\u7528init\uff0c\u800c\u662f\u81ea\u5df1\u6765\u5173\u673a\u3002\u4e0d\u9f13\u52b1\u4f7f\u7528\u8fd9\u4e2a\u9009\u9879\uff0c\u800c\u4e14\u8be5\u9009\u9879\u6240\u4ea7\u751f\u7684\u540e\u679c\u5f80\u5f80\u4e0d\u603b\u662f\u4f60\u6240\u9884\u671f\u5f97\u5230\u7684\u3002<\/li>\n

    \u3000\u3000<\/p>\n

  • [-c] cancel current process\u53d6\u6d88\u76ee\u524d\u6b63\u5728\u6267\u884c\u7684\u5173\u673a\u7a0b\u5e8f\u3002\u6240\u4ee5\u8fd9\u4e2a\u9009\u9879\u5f53\u7136\u6ca1\u6709\u65f6\u95f4\u53c2\u6570\uff0c\u4f46\u662f\u53ef\u4ee5\u8f93\u5165\u4e00\u4e2a\u7528\u6765\u89e3\u91ca\u7684\u8baf\u606f\uff0c\u800c\u8fd9\u4fe1\u606f\u5c06\u4f1a\u9001\u5230\u6bcf\u4f4d\u4f7f\u7528\u8005\u3002<\/li>\n

    \u3000<\/p>\n

  • [-f] \u5728\u91cd\u542f\u8ba1\u7b97\u5668(reboot)\u65f6\u5ffd\u7565fsck\u3002<\/li>\n

    \u3000<\/p>\n

  • [-F] \u5728\u91cd\u542f\u8ba1\u7b97\u5668(reboot)\u65f6\u5f3a\u8febfsck\u3002<\/li>\n

    \u3000<\/p>\n

  • [-time] \u8bbe\u5b9a\u5173\u673a(shutdown)\u524d\u7684\u65f6\u95f4\u3002<\/li>\n

    \"\"<\/p>\n

    2\u3001halt\u2014\u2014\u6700\u7b80\u5355\u7684\u5173\u673a\u547d\u4ee4<\/strong><\/span><\/div>\n

    \u5176\u5b9ehalt\u5c31\u662f\u8c03\u7528shutdown -h\u3002halt\u6267\u884c\u65f6\uff0c\u6740\u6b7b\u5e94\u7528\u8fdb\u7a0b\uff0c\u6267\u884csync\u7cfb\u7edf\u8c03\u7528\uff0c\u6587\u4ef6\u7cfb\u7edf\u5199\u64cd\u4f5c\u5b8c\u6210\u540e\u5c31\u4f1a\u505c\u6b62\u5185\u6838\u3002<\/p>\n

    \u53c2\u6570\u8bf4\u660e\uff1a<\/p>\n

  • [-n] \u9632\u6b62sync\u7cfb\u7edf\u8c03\u7528\uff0c\u5b83\u7528\u5728\u7528fsck\u4fee\u8865\u6839\u5206\u533a\u4e4b\u540e\uff0c\u4ee5\u963b\u6b62\u5185\u6838\u7528\u8001\u7248\u672c\u7684\u8d85\u7ea7\u5757(superblock)\u8986\u76d6\u4fee\u8865\u8fc7\u7684\u8d85\u7ea7\u5757\u3002<\/li>\n

    \u3000\u3000<\/p>\n

  • [-w] \u5e76\u4e0d\u662f\u771f\u6b63\u7684\u91cd\u542f\u6216\u5173\u673a\uff0c\u53ea\u662f\u5199wtmp(\/var\/log\/wtmp)\u7eaa\u5f55\u3002<\/li>\n

    \u3000\u3000<\/p>\n

  • [-d] \u4e0d\u5199wtmp\u7eaa\u5f55(\u5df2\u5305\u542b\u5728\u9009\u9879[-n]\u4e2d)\u3002<\/li>\n

    \u3000\u3000<\/p>\n

  • [-f] \u6ca1\u6709\u8c03\u7528shutdown\u800c\u5f3a\u5236\u5173\u673a\u6216\u91cd\u542f\u3002<\/li>\n

    \u3000\u3000<\/p>\n

  • [-i] \u5173\u673a(\u6216\u91cd\u542f)\u524d\uff0c\u5173\u6389\u6240\u6709\u7684\u7f51\u7edc\u63a5\u53e3\u3002<\/li>\n

    \u3000\u3000<\/p>\n

  • [-p] \u8be5\u9009\u9879\u4e3a\u7f3a\u7701\u9009\u9879\u3002\u5c31\u662f\u5173\u673a\u65f6\u8c03\u7528poweroff\u3002<\/li>\n
    3\u3001reboot<\/strong><\/span><\/div>\n

    reboot\u7684\u5de5\u4f5c\u8fc7\u7a0b\u5dee\u4e0d\u591a\u8ddfhalt\u4e00\u6837\uff0c\u4e0d\u8fc7\u5b83\u662f\u5f15\u53d1\u4e3b\u673a\u91cd\u542f\uff0c\u800chalt\u662f\u5173\u673a\uff0c\u5b83\u7684\u53c2\u6570\u4e0ehalt\u76f8\u5dee\u4e0d\u591a\u3002<\/p>\n

    4\u3001init<\/strong><\/span><\/div>\n

    init\u662f\u6240\u6709\u8fdb\u7a0b\u7684\u7956\u5148\uff0c\u5b83\u7684\u8fdb\u7a0b\u53f7\u59cb\u7ec8\u4e3a1\uff0c\u6240\u4ee5\u53d1\u9001TERM\u4fe1\u53f7\u7ed9init\u4f1a\u7ec8\u6b62\u6240\u6709\u7684\u7528\u6237\u8fdb\u7a0b\ufe51\u5b88\u62a4\u8fdb\u7a0b\u7b49\u3002shutdown\u5c31\u662f\u4f7f\u7528\u8fd9\u79cd\u673a\u5236\u3002init\u5b9a\u4e49\u4e868\u4e2a\u8fd0\u884c\u7ea7\u522b(runlevel)\uff0cinit 0\u4e3a\u5173\u673a\uff0cinit 1\u4e3a\u91cd\u542f\u3002\u53e6\u5916\u8fd8\u6709telinit\u547d\u4ee4\u53ef\u4ee5\u6539\u53d8init\u7684\u8fd0\u884c\u7ea7\u522b\uff0c\u6bd4\u5982telinit -iS\u53ef\u4f7f\u7cfb\u7edf\u8fdb\u5165\u5355\u7528\u6237\u6a21\u5f0f\uff0c\u5e76\u4e14\u5f97\u4e0d\u5230\u4f7f\u7528shutdown\u65f6\u7684\u4fe1\u606f\u548c\u7b49\u5f85\u65f6\u95f4\u3002<\/p>\n

    \"\"<\/p>\n

    \u5173\u4e8elinux\u5173\u673a\u547d\u4ee4\u662f\u4ec0\u4e48\u7684\u4ecb\u7ecd\u5c31\u5230\u8fd9\u91cc\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u6709\u6240\u5e2e\u52a9!<\/p>\n","protected":false},"excerpt":{"rendered":"

    \u5728linux\u4e0b\u4e00\u4e9b\u5e38\u7528\u7684\u5173\u673a\/\u91cd\u542f\u547d\u4ee4\u6709shutdown\u3001halt\u3001reboot\u3001\u53cainit\uff0c\u5b83\u4eec\u90fd\u53ef\u4ee5\u8fbe\u5230\u91cd […]<\/p>\n","protected":false},"author":310,"featured_media":259221,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-259207","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\/259207","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\/310"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=259207"}],"version-history":[{"count":13,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/259207\/revisions"}],"predecessor-version":[{"id":260163,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/259207\/revisions\/260163"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/259221"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=259207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=259207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=259207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}