51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

CentOS7更改时区

用timedatectl命令查看当前服务器时区设置:
Local time: Mon 2017-03-27 20:14:15 CST Universal time: Mon 2017-03-27 12:14:15 UTC RTC time: Mon 2017-03-27 12:14:15 Time zone: Asia/Shanghai (CST, +0800) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: n/a

|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 1 2 3 4 5 6 7 8 | Local time: Mon 2017-03-27 20:14:15 CST Universal time: Mon 2017-03-27 12:14:15 UTC RTC time: Mon 2017-03-27 12:14:15 Time zone: Asia/Shanghai (CST, +0800) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: n/a |

查看所有时区timedatectl list-timezones

更改成上海时区timedatectl set-timezone Asia/Shanghai

设置NTP开启timedatectl set-ntp yes

设置NTP关闭timedatectl set-ntp no

timedatectl命令也可以设置时间和日期

设置日期格式timedatectl set-time YYYY-MM-DD

设置时间格式timedatectl set-time HH:MM:SS

同步阿里云时间服务器/usr/sbin/ntpdate ntp1.aliyun.com

赞(0)
未经允许不得转载:工具盒子 » CentOS7更改时区