1. Viewing and modifying the Linux time zone and time
One, the Linux time zone view and the modification
1. View the current time zone
Date-r
2. Modify the setting time zone
Method 1:
Tzselect
Method 2:
Redhat Linux and CentOS only
Timeconfig
Method 3:
Suitable for 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, the Linux time viewing and modification
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/10/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
The commands used in Linux for clock viewing and setup 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
[HTML] view Plaincopyprint?
- Hwclock–hctosys
- #或
- Clock–hctosys
To modify the Linux system time:
Date-s (back and time)
To view Linux hardware time:
Java code
[HTML]View Plaincopyprint?
- Hwclock
- #或
- Clock
- #或
- Hwclock–show
- #或
- Clock–show
To modify the Linux hardware time:
C code
[CSharp]View Plaincopyprint?
- hwclock–set–date
- #或
- clock–set–date
To synchronize the system time with the hardware clock, use:
C code
[HTML]View Plaincopyprint?
- Hwclock–hctosys
- #或
- Clock–hctosys
Instead, let the hardware clock synchronize with the system time:
C code
[HTML]View Plaincopyprint?
- Hwclock–systohc
- #或
- Clock–systohc
Allow the system time to synchronize hardware time every 10 minutes.
C code
[HTML]View Plaincopyprint?
- [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.daily
- 4 * * 0 root run-parts/etc/cron.weekly
- 4 1 * * Root run-parts/etc/cron.monthly
- */10 * * * * root hwclock--hctosys #加入此行, Hwclock--hctosys every 10 minutes
CentOS Time View Modify Command date explanation