One, time zone
1, view or modify the system time method is as follows:
The code is as follows |
Copy Code |
#date View System time #date-S modification time, see the following example #date-S 05/16/2010 (set the system date to May 16, 2010) #date-S 12:40:22 (set system time to 12:40:22) |
Execution after modification: clock-w, forcing time to be written to COMs
2. Modify the time zone method: (Write the asia/shanghai-Shanghai time zone to the current time zone)
The code is as follows |
Copy Code |
Cp-f/usr/share/zoneinfo/asia/shanghai/etc/localtime |
Tip Whether to overwrite, enter Y return, and then
Date
View time zone and time (CST, China time zone)
3, set the time synchronization method (the following to run as root user)
Use Ntpdate calibration time, not installed, first install NTP
The code is as follows |
Copy Code |
Yum Install Ntp-y Use Windows Server to synchronize standard time Ntpdate time.windows.com The ntpdate time.windows.com can be added to the crontab to synchronize regularly. Transport crontab: Crontab–e Found: -bash:crontab:command not found Minimized version is not with crontab Install Crontab: Yum Install Cronie-y To see if the installation was successful: Crontab-l No crontab for root indicates successful installation Set to boot up: Chkconfig--level 2345 Crond on Start crontab: Service Crond Start Set automatic sync every 23:59 Crontab-e * * * * ntpdate time.windows.com |
Modify Time Zone
The code is as follows |
Copy Code |
Cp/usr/share/zoneinfo/asia/shanghai/etc/localtime |
Time zone information exists under/usr/share/zoneinfo/, the local time zone information exists/etc/localtime, using the tab skill, you can modify the time zone arbitrarily
Tzselect, interactive command, but it seems not too good, or use the above bar.
Second, time
Concept: Linux time has two
System time: Also called software time (SYS), the number of seconds from January 1, 1970 to the current time
Bois time: Also called hardware time (HC)
Show time
[Root@localhost ~]# Date;hwclock-r
Friday, October 19, 2012 23:39:44 CST
October 19, 2012 Friday 23:39 45 sec -0.317993 seconds
Set time
1, Date-s
Date-s 20121019
Date-s 23:40:00
You can use this if you don't have a network.
2, Ntpdate
Do not install ntpdate can yum:
Yum Install-y ntpdate
Join Scheduled Tasks and sync clocks every 10 minutes
Crontab-e
0-59/10 * * * */usr/sbin/ntpdate time.windows.com | Logger-t NTP
In this way, we can solve the problem of inaccurate time in the CentOS system.
Date-s//Set the current time, only root permission to set, others can only view.
Date-s 20061010//set to 20061010, this will set the specific time to empty 00:00:00
Date-s 12:23:23//Set specific time, do not make changes to date
Date-s "12:12:23 2006-10-10″//so you can set all the time