Modify the system time zone liunx

System time

Check the system time date

Setting the system time date -s (month / day / year hours: minutes: seconds)

[root@localhost ~]# rm -rf  /etc/localtime
[root@localhost ~]# ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

Now we must get a solution to time jvm execution and system time inconsistencies. Access to information through the Internet, should be the time zone setting jvm running problem.
There are several ways to solve:

1, in the program using the java function setting time zone.
2, additional parameters -Duser.timezone = GMT + 8 at start java program
3, the time zone setting adjustment system

 [root@localhost ~]#vi /etc/sysconfig/clock   #编辑时间配置文件
    ZONE="Asia/Shanghai"
    UTC=false                   #设置为false,硬件时钟不于utc时间一致
    ARC=false
[root@localhost ~]#ln -sf /usr/share/zoneinfo/Asia/Shanghai    /etc/localtime    #linux的时区设置为上海时区
[root@localhost ~]#ntpdate cn.pool.ntp.org    #对准时间
[root@localhost ~]#/sbin/hwclock --systohc   #设置硬件时间和系统时间一致并校准 

Find / etc / sysconfig / clock configuration file of time zone or New York time, no wonder the difference of nearly eight hours slightly. It may be time to install the system in no time zone is not the default choice of New York time.

Time is not the same, a difference of eight hours, you can check whether the database server at the same time time. If not, modify the service first time, the database will be restarted.

Synchronization Network

ntpdate command:

 [root@localhost ~]#ntpdate -u 210.72.145.44 :网络时间同步命令

Note: If adding -u parameter, the following prompts: NO Suitable for Server Synchronization found
-u: As can be seen from the man ntpdate -u parameter can cross the firewall and host synchronization;
be input the blank: China National Time Service Center of The official server.

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

Set hardware time
to view the hardware time

[root@localhost ~]#hwclock --show

or

[root@localhost ~]#clock --show

Set hardware time

[root@localhost ~]#hwclock --set --date="07/07/06 10:19" (月/日/年 时:分:秒)

or

[root@localhost ~]# clock --set --date="07/07/06 10:19" (月/日/年 时:分:秒)

Synchronize system time and hardware time
in accordance with the previous statement, restart the system, the hardware will read the system time to time, synchronization, but when not restart, the need to achieve synchronization with a clock or hwclock command.
Hardware and system clocks synchronized: # hwclock --hctosys (hc represent hardware time, sys represents the system time) or # clock --hctosys
system clock and hardware clock synchronization: # hwclock --systohc or # clock --systohc

发布了197 篇原创文章 · 获赞 30 · 访问量 8万+

Guess you like

Origin blog.csdn.net/Rio520/article/details/104370607