Centos various time [system time/hardware time]

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

date -s 10/12/2012

2012 Friday, October 12, 00:00:00 CST

First, check and modify the time zone configuration:

cat /etc/timezone

Asia/Beijing
Next, check the configuration file of the system time

cat /etc/sysconfig/clock

ZONE=”Asia/Beijing”
UTC=false
ARC=false
Make sure that the above Zone environment configuration is corresponding. Then modify the local time file:

cd /usr/share/zoneinfo/Asia/

cp Beijing /etc/localtime

Copy the correct local time file (or link)
Finally, reset the hardware time to the system time and restart to take effect:

hwclock –hctosys

If you want to quickly set Beijing time: (update to a server time)

ntpdate cn.pool.ntp.org

Recommended Posts

Centos various time [system time/hardware time]
Centos system modify time zone
centos system management
01 CentOS 7.6 switch system language
CentOS7.5-1804 system kernel upgrade
CentOS system startup process
VirtualBox install CentOS system
Centos7.2 system optimization original
Centos system process management
CentOS system optimization script, unfinished
Centos7 system commonly used commands
Install docker on Centos system
Centos backend system setup record
Centos6 system boot loading process
Linux centos system boot process
CentOS 6.X system initialization script
CentOS 7.X system installation and optimization
CentOS7.2 install lepus database monitoring system
Install Centos7 operating system in Docker
001. Installation of enterprise-level CentOS7.6 operating system
Modify CentOS server time to Beijing time