View/modify Linux time zone and time
One, time zone
1. View the current time zone
Date-r
2. Modify the settings time zone
Method (1)
Tzselect
Method (2) limited to Redhat Linux and CentOS
Timeconfig
Method (3) applies to Debian
Dpkg-reconfigure Tzdata
3. Copy the appropriate time zone file, replace the system time zone file, or create a linked file
cp/usr/share/zoneinfo/$ main time zone/$ times time zone/etc/localtime
Can be used in China:
Cp/usr/share/zoneinfo/asia/shanghai/etc/localtime
Second, time
1. Check the time and date
Date
2. Set time and date
command to set the system date to June 10, 1996
Date-s 06/22/96
command to set the system time to 1:52 P.M. 0 seconds
Date-s 13:52:00
3. Write the current time and date to the BIOS to avoid failure after reboot
Hwclock-w
Three, timing synchronization time
* * * * * */usr/sbin/ntpdate 210.72.145.44 >/dev/null 2>&1
In Linux, the commands used for clock viewing and setting are mainly date, hwclock, and clock. Among them, clock and hwclock usage similar, only one on the line, but clock command in addition to support x86 hardware system, but also support the Alpha hardware system.
To view Linux system time:
Date
To modify the Linux system time:
Date-s (back and time)
To view Linux hardware time:
Hwclock
Or
Clock
Or
Hwclock–show
Or
Clock–show
To modify the Linux hardware time:
Hwclock–set–date
Or
Clock–set–date
To synchronize the system time with the hardware clock, use:
Hwclock–hctosys
Or
Clock–hctosys
Instead, let the hardware clock synchronize with the system time:
Hwclock–systohc
Or
Clock–systohc
Allow the system time to synchronize hardware time every 10 minutes.
[Email protected] root]$ vi/etc/crontab shell=/bin/bash path=/sbin:/bin:/usr/sbin:/usr/bin mailto= Root home=/ # run-parts * * * * * root run-parts/etc/cron.hourly 4 * * * Root Run-parts/etc/cron.dai LY 4 * * 0 root run-parts/etc/cron.weekly 4 1 * * Root run-parts/etc/cron.monthly */10 * * * * root HW Clock--hctosys #我加入了这么一行, which indicates that Hwclock--hctosys is performed every 10 minutes.
View modify Linux time zone and time