View and modify time zone time in Linux

1. View and modify Linux time zone and time
 
1. View and modify Linux time zone
 
1. View current time zone
date -R
 
2, modify and set time zone
Method 1:
tzselect
 
Method 2:
Only for RedHat Linux and CentOS
timeconfig
 
Method 3: For
Debian
dpkg-reconfigure tzdata
 
3, copy the corresponding time zone file and replace the system time zone file; or create a link file
cp /usr/share/zoneinfo/$primary time zone/$ secondary time zone/etc/localtime
 
In China, you can use:
cp /usr/share /zoneinfo/Asia/Shanghai /etc/localtime
 
2. View and modify linux time
 
1. View time and date
date
 
2. Set time and date
to set the system date to June 10, 1996 Command
date -s 06/ 22/96
 
Set the system time to 1:52:00 pm with the command
date -s 13:52:00
 
3. Write the current time and date into the BIOS to avoid failure after restarting
hwclock -w
 
3. Timing synchronization time
 
* * * * * /usr/sbin/ntpdate 210.72.145.44 > /dev/null 2>&1
 
The commands used to view and set the clock in Linux mainly include date, hwclock and clock.
Among them, the usage of clock and hwclock are similar, only one is needed, but the clock command supports Alpha hardware system in addition to x86 hardware system.
 
View Linux system time:
date
 
Modify Linux system time:
date -s (followed by time)
 
View Linux hardware time:
Java code 
hwclock 
# or 
clock 
# or 
hwclock –show 
# or 
clock –show 
 
Modify Linux hardware time:
C code 
hwclock –set –date 
# or 
clock –set –date 
 
to synchronize the system time with the hardware clock, use:
C code 
hwclock –hctosys 
# or 
clock –hctosys 
 
Conversely, to synchronize the hardware clock with the system time:
C code 
hwclock –systohc 
# or 
clock –systohc 
 
Let the system time synchronize the hardware time every ten minutes.
C code 
[hqw@localhost root]$ vi /etc/crontab 
SHELL=/bin/bash 
PATH=/sbin:/bin:/usr/sbin:/usr/bin 
MAILTO=root 
HOME=/ 
# run-parts 
01 * * * * root run-parts /etc/cron.hourly 
02 4 * * * root run-parts /etc/cron.daily 
22 4 * * 0 root run-parts /etc/cron.weekly 
42 4 1 * * root run- parts /etc/cron.monthly 
*/10 * * * * root hwclock --hctosys #Add this line to execute hwclock --hctosys every 10 minutes 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327088603&siteId=291194637