CentOS7修改时区

将服务器时间类型改为UTC
方法一:

timedatectl set-timezone UTC
timedatectl set-time "YYYY-MM-DD HH:MM:SS"
timedatectl set-time "HH:MM:SS"
timedatectl

我们可以看到,服务器时间类型更改为UTC了
ll /etc/locatime
lrwxrwxrwx. 1 root root 25 1月 14 08:30 /etc/localtime -> ../usr/share/zoneinfo/UTC

实际上是做了一个将
文件 /etc/localtime 做了一个软连接到 /usr/share/zoneinfo/UTC

方法二:
ln -s /usr/share/zoneinfo/UTC /etc/localtime
ln: 无法创建符号链接"/etc/localtime": 文件已存在
ln -sf /usr/share/zoneinfo/UTC /etc/localtime

做软连接时,需要加 -f 参数,强制覆盖,不然会显示软链接已存在
timedatectl set-time "YYYY-MM-DD HH:MM:SS"
timedatectl set-time "HH:MM:SS" //只设置时分秒
timedatectl

点赞

发表评论

电子邮件地址不会被公开。必填项已用 * 标注