CentOS下快速修改时区

linux在安装的时候如果时区选择错误,可以在系统安装完成之后修改。系统时间运行着也会有偏差,需要对时间进行实时同步,本篇文章为大家讲解一下快速修改时区具体方法。

方法1: timedatectl set-timezone Asia/Shanghai

# timedatectl
Warning: Ignoring the TZ variable. Reading the system's time zone setting only. Local time: Mon 2016-11-21 01:52:42 EST Universal time: Mon 2016-11-21 06:52:42 UTC RTC time: Mon 2016-11-21 06:52:42 Time zone: America/New_York (EST, -0500) NTP enabled: n/a NTP synchronized: no RTC in local TZ: no DST active: no Last DST change: DST ended at Sun 2016-11-06 01:59:59 EDT Sun 2016-11-06 01:00:00 EST Next DST change: DST begins (the clock jumps one hour forward) at Sun 2017-03-12 01:59:59 EST Sun 2017-03-12 03:00:00 EDT 

设置时区为CST(东8区)

# timedatectl  set-timezone Asia/Shanghai
Warning: Ignoring the TZ variable. Reading the system's time zone setting only. Local time: Mon 2016-11-21 14:52:59 CST Universal time: Mon 2016-11-21 06:52:59 UTC RTC time: Mon 2016-11-21 06:52:59 Time zone: Asia/Shanghai (CST, +0800) NTP enabled: n/a NTP synchronized: no RTC in local TZ: no DST active: n/a [root@localhost ~]# 

方法2:TZ环境变量的方式

修改用户目录下的.bash_profile,在文件末尾追加:

TZ='Asia/Shanghai'export TZ

推出登录后,重新登录,date命令可以查看效果。

原创文章,作者:晴川运维,如若转载,请注明出处:https://baike.qcidc.com/7306.html

(0)
晴川运维晴川运维
上一篇 2025年6月9日
下一篇 2025年6月9日

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注