View and modify CentOS time
1. view and modify the Linux time zone and time
I. Viewing and modifying linux time zones
1. view the current time zone
Date-R
2. Modify the time zone
Method 1:
Tzselect
Method 2:
Limited to RedHat Linux and CentOS
Timeconfig
Method 3:
Applicable to Debian
Dpkg-reconfigure tzdata
3. Copy the corresponding time zone file, replace the system time zone file, or create a link file.
Cp/usr/share/zoneinfo/$ main Time Zone/$ Time Zone/etc/localtime
Available in China:
Cp/usr/share/zoneinfo/Asia/Shanghai/etc/localtime
Ii. Viewing and modifying linux time
1. view the time and date
Date
2. Set the time and date
Set the system date to June 10, 1996.
Data-s 06/22/96
Set the system time to 01:52:00 P.M..
Date-s 13:52:00
3. Write the current time and date to the BIOS to prevent failure after restart
Hwclock-w
Iii. Scheduled synchronization time
* ***/Usr/sbin/ntpdate 210.72.145.44>/dev/null 2> & 1
In Linux, the commands used for clock viewing and setting mainly include date, hwclock, and clock.
Among them, clock and hwclock use similar, just use one line, but clock commands not only support x86 hardware system, but also support Alpha hardware system.
View the Linux system time:
Date
[Html] view plaincopyprint?
- Hwclock-hctosys
- # Or
- Clock-hctosys
Linux system modification time:
Date-s (followed by Time)
View Linux hardware time:
Java code
[Html] view plaincopyprint?
- Hwclock
- # Or
- Clock
- # Or
- Hwclock-show
- # Or
- Clock-show
Linux hardware modification time:
C code
[Csharp] view plaincopyprint?
- Hwclock-set-date
- # Or
- Clock-set-date
Synchronize the system time with the hardware clock:
C code
[Html] view plaincopyprint?
- Hwclock-hctosys
- # Or
- Clock-hctosys
On the contrary, synchronize the hardware clock with the system time:
C code
[Html] view plaincopyprint?
- Hwclock-systohc
- # Or
- Clock-systohc
Let the system synchronize the hardware time every ten minutes.
C code
[Html] view plaincopyprint?
- [Hqw @ localhostroot] $ vi/etc/crontab
- SHELL =/bin/bash
- PATH =/sbin:/bin:/usr/sbin:/usr/bin
- MAILTO = root
- HOME =/
- # Run-parts
- 01 ***** rootrun-parts/etc/cron. hourly
- 024 *** rootrun-parts/etc/cron. daily
- 224 ** 0rootrun-parts/etc/cron. weekly
- 4241 ** rootrun-parts/etc/cron. monthly
- */10 * roothwclock -- hctosys # Add this row and run hwclock -- hctosys every 10 minutes.