The time for Linux is divided into system Clock (systems time) and real times Clock (hardware time, referred to as RTC).
System time: Refers to the time in the current Linux kernel.
Hardware time: The motherboard has battery-powered time.
To view system time commands: #date
To set the system time command: #date –set (Month/day/year: minutes: seconds)
Example: #date –set "10/11/10 10:15"
command to view hardware time: # Hwclock
To set the hardware time command: # hwclock–set–date = (month/day/year: minutes: seconds)
The above mentioned is manually set time to a point in time, possibly with the current network time error. Here's how to synchronize time with time server
1. Install Ntpdate Tools
# yum-y Install NTP ntpdate
2. Set the system time and network time synchronization
# ntpdate Cn.pool.ntp.org
3. Write system time to hardware time
# Hwclock--SYSTOHC
4. Force the system time to write CMOS to prevent restart failure
Hwclock-w
or clock-w
After installing the CentOS Linux operating system, the time we clicked on the system was found to be inconsistent with the time we are using, the difference is 8 hours, and when the system is installed we choose the time zone is Shanghai, but CentOS linux default Bios time is UTC time ( UTC is the coordinated World time (Universal Time coordinated) English abbreviation, which is defined and recommended by the International Radio Advisory Board and is maintained by the International Time Bureau (BIH) in seconds based timescale. UTC, which corresponds to the average sun on the meridian (i.e. longitude 0 degrees), was previously represented by Greenwich Mean Time (GMT). Beijing time is 8 hours earlier than UTC, with January 1, 1999 0000UTC as an example, UTC time is 0, Beijing time is January 1, 1999 8 o'clock in the morning whole. , so we were 8 hours apart in time. This time the BIOS time and system time of course is inconsistent, one represents UTC time, one represents CST (+8 time zone), that is, the time in Shanghai.
Let's try to sync the operating system time!
Execute the following command in the CentOS Linux Terminal command:
1, Vi/etc/sysconfig/clock #编辑时间配置文件
Zone= "Asia/shanghai"
Utc=false #设置为false, hardware clock is not consistent with UTC time
Arc=false
2, Ln-sf/usr/share/zoneinfo/asia/shanghai/etc/localtime #linux的时区设置为上海时区
3, Ntpdate 192.43.244.18 #对准时间
If you do not have an NTP server installed, you just need to execute the following command first:
Yum Install NTP #安装ntp服务器
4,/sbin/hwclock--SYSTOHC #设置硬件时间和系统时间一致并校准
Well, our CentOS Linux system time and computer hardware time are finally CST time, and are the Shanghai time zone, finally is normal.