This article is from a network collection, the red ones are the places where I remarked
The first thing to know is the concept of time in the Linux system:
1 ) In Linux system, system time and hardware time are independent
System time refers to the running time in the system, and hardware time refers to the time in hardware devices, such as BIOS.
2 ) The relationship between system time and hardware time
The system time is set by the hardware time and the system time zone. When the system starts, it will read the hardware time from the hardware device, modify it according to the system time zone, and then write it into the system time. Similarly, when the system is shut down, the system time will be read and then the hardware time will be written.
For problems caused by hardware, please contact the hardware supplier. Let's talk about the solutions on the system:
1、 The documents involved are:
Reference /etc/localtime-local time file (binary file)
/etc/sysconfig/clock-system time configuration file
/etc/timezone-system time zone file (I didn't find it in my centos)
And a directory:
/usr/share/zoneinfo-the local time file that the system can use
2、 Commands used
/bin/date-view system time
/sbin/hwclock-View the hardware or system time, and modify the hardware time
3. Joyous example
System: Centos 6.2
Usually, since our time zone is GMT +8 (China), if there is a problem, we will find this situation:
Quote
2012 Friday, October 12, 00:00:00 CST
First, check and modify the time zone configuration:
Asia/Beijing
Next, check the configuration file of the system time
ZONE=”Asia/Beijing”
UTC=false
ARC=false
Make sure that the above Zone environment configuration is corresponding. Then modify the local time file:
Copy the correct local time file (or link)
Finally, reset the hardware time to the system time and restart to take effect:
If you want to quickly set Beijing time: (update to a server time)
ntpdate cn.pool.ntp.org
Recommended Posts