linux同步时间网络指定时区

Linux时间设置

1.date ‘+%Y%M%D’ 按照格式显示当前日期,结果如下:

[root@LAMP ~]# date "+%Y-%m-%d %H:%M:%S"
2016-08-16 20:01:25

2.date -s “xxx xx:xx:xx” 设置系统时间:

[root@LAMP ~]# date -s "20160819 15:30:30"
Fri Aug 19 15:30:30 HKT 2016

3.时间同步服务器:

[root@LAMP ~]# ntpdate -u ntp.api.bz
29 Apr 15:26:27 ntpdate[2667]: step time server 61.153.197.226 offset -311.570389 sec
ntp常用服务器:

中国国家授时中心:210.72.145.44
NTP服务器(上海) :ntp.api.bz
美国: time.nist.gov
复旦: ntp.fudan.edu.cn
微软公司授时主机(美国) :time.windows.com
北京邮电大学 : s1a.time.edu.cn
清华大学 : s1b.time.edu.cn
北京大学 : s1c.time.edu.cn
台警大授时中心(台湾):asia.pool.ntp.org

4.时区操作:

1).查看时区 date “+%Z”
[root@LAMP ~]# date "+%Z"
HKT
2).使用cat /etc/sysconfig/clock查看当前时区
[root@LAMP ~]# cat /etc/sysconfig/clock
ZONE="Asia/Hong_Kong"

设置时区

[root@LAMP ~]# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
cp: overwrite `/etc/localtime'? y
[root@LAMP ~]# date "+%Z"
CST

5.将系统时间写入硬件:

查看硬件时间
hwclock
同步系统时间
clock -w

[root@LAMP ~]# hwclock 
Tue 16 Aug 2016 08:09:24 PM CST  -0.456264 seconds
[root@LAMP ~]# hwclock -w
[root@LAMP ~]# hwclock 
Fri 19 Aug 2016 12:24:08 AM CST  -0.986792 seconds

原文出处—头痛不头痛

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值