{"id":41631,"date":"2023-03-05T09:45:43","date_gmt":"2023-03-05T01:45:43","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=41631"},"modified":"2023-03-05T09:45:43","modified_gmt":"2023-03-05T01:45:43","slug":"linux-time-zone","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-time-zone.html","title":{"rendered":"\u5927\u795e\u6559\u4f60\u5728 Linux \u4e2d\u67e5\u770b\u4f60\u7684\u65f6\u533a"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u5728\u8fd9\u7bc7\u77ed\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u5411\u4f60\u7b80\u5355\u4ecb\u7ecd\u51e0\u79cd Linux \u4e0b\u67e5\u770b\u7cfb\u7edf\u65f6\u533a\u7684\u7b80\u5355\u65b9\u6cd5\u3002\u5728 Linux \u673a\u5668\u4e2d\uff0c\u5c24\u5176\u662f\u751f\u4ea7\u670d\u52a1\u5668\u4e0a\u7684\u65f6\u95f4\u7ba1\u7406\u6280\u80fd\uff0c\u662f\u5728\u7cfb\u7edf\u7ba1\u7406\u4e2d\u4e00\u4e2a\u6781\u5176\u91cd\u8981\u7684\u65b9\u9762\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

Linux \u5305\u542b\u591a\u79cd\u53ef\u7528\u7684\u65f6\u95f4\u7ba1\u7406\u5de5\u5177\uff0c\u6bd4\u5982 date<\/span> \u6216 timedatectlcommands<\/span>\uff0c\u4f60\u53ef\u4ee5\u7528\u5b83\u4eec\u6765\u83b7\u53d6\u5f53\u524d\u7cfb\u7edf\u65f6\u533a\uff0c\u4e5f\u53ef\u4ee5\u5c06\u7cfb\u7edf\u65f6\u95f4\u4e0e NTP \u670d\u52a1\u5668\u540c\u6b65\uff0c\u6765\u81ea\u52a8\u5730\u3001\u66f4\u7cbe\u786e\u5730\u8fdb\u884c\u65f6\u95f4\u7ba1\u7406\u3002<\/p>\n

\u597d\uff0c\u6211\u4eec\u4e00\u8d77\u6765\u770b\u51e0\u79cd\u67e5\u770b\u6211\u4eec\u7684 Linux \u7cfb\u7edf\u65f6\u533a\u7684\u4e0d\u540c\u65b9\u6cd5\u3002<\/p>\n

1\u3001\u6211\u4eec\u4ece\u4f7f\u7528\u4f20\u7edf\u7684 date \u547d\u4ee4\u5f00\u59cb<\/strong><\/div>\n

\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\uff0c\u6765\u770b\u4e00\u770b\u6211\u4eec\u7684\u5f53\u524d\u65f6\u533a\uff1a<\/p>\n

$ date\r\n<\/pre>\n

\u6216\u8005\uff0c\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u3002\u5176\u4e2d %Z<\/span> \u683c\u5f0f\u53ef\u4ee5\u8f93\u51fa\u5b57\u7b26\u5f62\u5f0f\u7684\u65f6\u533a\uff0c\u800c %z<\/span> \u8f93\u51fa\u6570\u5b57\u5f62\u5f0f\u7684\u65f6\u533a\uff1a<\/p>\n

$ date +\u201d%Z %z\u201d\r\n<\/pre>\n

\"\u5728<\/p>\n

\u67e5\u770b Linux \u65f6\u533a<\/em><\/p>\n

\u6ce8\u610f\uff1adate<\/span>\u7684\u624b\u518c\u9875\u4e2d\u5305\u542b\u5f88\u591a\u8f93\u51fa\u683c\u5f0f\uff0c\u4f60\u53ef\u4ee5\u5229\u7528\u5b83\u4eec\uff0c\u6765\u66ff\u6362\u4f60\u7684 date<\/span> \u547d\u4ee4\u7684\u8f93\u51fa\u5185\u5bb9\uff1a<\/p>\n

$ man date\r\n<\/pre>\n
2\u3001\u63a5\u4e0b\u6765\uff0c\u4f60\u540c\u6837\u53ef\u4ee5\u7528 timedatectl \u547d\u4ee4<\/strong><\/div>\n

\u5f53\u4f60\u4e0d\u5e26\u4efb\u4f55\u53c2\u6570\u8fd0\u884c\u5b83\u65f6\uff0c\u8fd9\u6761\u547d\u4ee4\u53ef\u4ee5\u50cf\u4e0b\u56fe\u4e00\u6837\uff0c\u8f93\u51fa\u7cfb\u7edf\u65f6\u95f4\u6982\u89c8\uff0c\u5176\u4e2d\u5305\u542b\u5f53\u524d\u65f6\u533a\uff1a<\/p>\n

$ timedatectl\r\n<\/pre>\n

\u7136\u540e\uff0c\u4f60\u53ef\u4ee5\u5728\u547d\u4ee4\u4e2d\u63d0\u4f9b\u4e00\u6761\u7ba1\u9053\uff0c\u7136\u540e\u7528 grep \u547d\u4ee4\u6765\u50cf\u4e0b\u9762\u4e00\u6837\uff0c\u53ea\u8fc7\u6ee4\u51fa\u65f6\u533a\u4fe1\u606f\uff1a<\/p>\n

$ timedatectl | grep \u201cTime zone\u201d\r\n<\/pre>\n

\"\u5728<\/p>\n

\u67e5\u770b\u5f53\u524d Linux \u65f6\u533a<\/em><\/p>\n

\u540c\u6837\uff0c\u6211\u4eec\u53ef\u4ee5\u5b66\u4e60\u5982\u4f55\u4f7f\u7528 timedatectl \u6765\u8bbe\u7f6e Linux \u65f6\u533a\u3002<\/p>\n

3\u3001\u8fdb\u4e00\u6b65\uff0c\u663e\u793a\u6587\u4ef6 \/etc\/timezone \u7684\u5185\u5bb9<\/strong><\/div>\n

\u4f7f\u7528 cat \u5de5\u5177\u663e\u793a\u6587\u4ef6 \/etc\/timezone<\/span>\u7684\u5185\u5bb9\uff0c\u6765\u67e5\u770b\u4f60\u7684\u65f6\u533a\uff1a<\/p>\n

$ cat \/etc\/timezone\r\n<\/pre>\n

\"\u5728<\/p>\n

\u5728 Linux \u4e2d\u67e5\u770b\u65f6\u533a<\/em><\/p>\n

\u5bf9\u4e8e RHEL\/CentOS\/Fedora \u7528\u6237\uff0c\u8fd9\u91cc\u8fd8\u6709\u4e00\u6761\u53ef\u4ee5\u8d77\u5230\u540c\u6837\u6548\u679c\u7684\u547d\u4ee4\uff1a<\/p>\n

$ grep ZONE \/etc\/sysconfig\/clock\r\n<\/pre>\n

\u5c31\u8fd9\u4e9b\u4e86\uff01\u522b\u5fd8\u4e86\u5728\u4e0b\u9762\u7684\u53cd\u9988\u680f\u4e2d\u5206\u4eab\u4f60\u5bf9\u4e8e\u8fd9\u7bc7\u6587\u7ae0\u4e2d\u7684\u770b\u6cd5\u3002\u91cd\u8981\u7684\u662f\uff1a\u4f60\u5e94\u8be5\u901a\u8fc7\u8fd9\u7bc7 Linux \u65f6\u533a\u7ba1\u7406\u6307\u5357\u6765\u5b66\u4e60\u66f4\u591a\u7cfb\u7edf\u65f6\u95f4\u7ba1\u7406\u7684\u77e5\u8bc6\uff0c\u56e0\u4e3a\u5b83\u542b\u6709\u5f88\u591a\u6613\u4e8e\u64cd\u4f5c\u7684\u5b9e\u4f8b\u3002<\/p>\n

\n

\u539f\u6587\u6765\u81ea\uff1ahttps:\/\/linux.cn:443\/article-7970-1.html<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1ahttp:\/\/lrxjmw.cn\/linux-time-zone.html<\/a>\u7f16\u8f91\u5458\uff1a\u70e8\u5b50\uff0c\u5ba1\u6838\u5458\uff1a\u51af\u742a<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u5728\u8fd9\u7bc7\u77ed\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u5411\u4f60\u7b80\u5355\u4ecb\u7ecd\u51e0\u79cd Linux \u4e0b\u67e5\u770b\u7cfb\u7edf\u65f6\u533a\u7684\u7b80\u5355\u65b9\u6cd5\u3002\u5728 Linux \u673a\u5668\u4e2d\uff0c\u5c24\u5176\u662f\u751f\u4ea7\u670d\u52a1\u5668\u4e0a\u7684\u65f6\u95f4\u7ba1\u7406\u6280\u80fd\uff0c\u662f\u5728\u7cfb\u7edf\u7ba1\u7406\u4e2d\u4e00\u4e2a\u6781\u5176\u91cd\u8981\u7684\u65b9\u9762\u3002<\/p>\n","protected":false},"author":63,"featured_media":42479,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-41631","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\/41631","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\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=41631"}],"version-history":[{"count":5,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/41631\/revisions"}],"predecessor-version":[{"id":266291,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/41631\/revisions\/266291"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/42479"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=41631"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=41631"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=41631"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}