修改Linux时间

linux修改系统时间

手动修改

1
date -s 04/28/19

修改日期为:2019/04/28

1
date -s 11:28:00

修改时间为11:28:00

或者一次:

1
date -s "2019-04-28 11:28:00"
1
hwclock -w

将时间写入bios避免重启失效

同步网络时间

1
yum install ntp

ntp常用服务器:

1
2
3
4
5
6
中国国家授时中心:210.72.145.44
NTP服务器(上海) :ntp.api.bz
美国:time.nist.gov
复旦:ntp.fudan.edu.cn
微软公司授时主机(美国) :time.windows.com
台警大授时中心(台湾):asia.pool.ntp.org

同步时间:

1
ntpdate -dv ntp.api.bz

同步完成之后,发现时间有点不对,12h误差

1
2
[root@localhost ~]# date
Sun Apr 28 01:20:14 EDT 2019

查了下,EDT是美国东部时间,需要改成北京时间

时区修改

1
2
3
4
5
mv /etc/localtime /etc/localtime.bak 

ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

date

完成~

文章目录
  1. 手动修改
  2. 同步网络时间
    1. 同步时间:
  3. 时区修改
|