Linux修改时间和时区

root 用户执行:

# mv /etc/localtime /etc/localtime_bak
# cp /usr/share/zoneinfo/Asia/Shanghai  /etc/localtime
# date
# ntpdate cn.pool.ntp.org
# echo 'Asia/Shanghai' >/etc/timezone

备份
将时间设置为上海时区的时间
如果时间仍然没有改变,执行下一条命令进行时间同步更新
如果提示:‘-bash: ntpdate: command not found’ 则执行 # yum -y install ntpdate 命令安装时间同步工具后再执行;
虽然通过上面的命令已经将时间修改为想要的时间,但是对应的时区可能还是以前的时区,此时需要执行这条命令进行时区修正

猜你喜欢

转载自www.cnblogs.com/xyarn/p/9592678.html