Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of adjusting system time and time Zone by Linux and Unix

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

The method of adjusting system time and time Zone by Linux and Unix

I. Linux adjusts the time zone

1) find the appropriate time zone file, such as adjusting to Asia / Shanghai time zone:

Ln-s / usr/share/zoneinfo/Asia/Shanghai / etc/localtime

Replace the current / etc/localtime file with this file.

2) modify the / etc/sysconfig/clock file to:

ZONE= "Asia/Shanghai"

UTC=false

ARC=false

3) adjust through tzselect

# tzselect

Please identify a location so that time zone rules can be set correctly.Please select a continent or ocean1) Africa2) Americas3) Antarctica4) Arctic Ocean5) Atlantic Ocean7) Atlantic Ocean7) Indian Ocean10) Pacific Ocean11) none-I want to specify the time zone using the Posix TZ format. Enter 5, 4) Bahrain21) Kazakhstan38) Russia5) Korea (North) 39) Saudi Arabia6) Bhutan23) Korea (South) 40) Singapore7) Kuwait41) Sri Lanka Cambodia25) Kyrgyzstan42) China input 9, China Please select one of the following time zone regions1) east China-Beijing, Guangdong, Shanghai, etc.2) Heilongjiang3) central China-Gansu, Guizhou, Sichuan, Yunnan, etc.4) Tibet & most of Xinjiang Uyghur5) southwest Xinjiang Uyghur input 1 The following information has been given:China east China-Beijing, Guangdong, Shanghai, etcTherefore TZ= "Asia/Shanghai" will be used.Local time is now: Fri Jul 7 10:32:18 CST 2006.Universal Time is now: Fri Jul 7 02:32:18 UTC 2006.Is the above information OK?1) Yes2) No enter 1, confirm

II. Change of Linux time

Linux clock is divided into system clock (System Clock) and hardware (Real Time Clock, referred to as RTC) clock. The system clock refers to the clock in the current Linux Kernel, while the hardware clock is the battery-powered clock on the motherboard, which can be set in the BIOS. When Linux starts, the hardware clock reads the setting of the system clock, and then the system clock operates independently of the hardware.

All commands in Linux, including functions, are set by the system clock. In Linux, the main commands for clock viewing and setting are date, hwclock, and clock. Among them, the use of clock and hwclock is similar, only one can be used, but the clock command supports not only x86 hardware architecture, but also Alpha hardware architecture.

1 、 date

View system time

# date

Set system time

# date-set "07Accord 07Accord 06 10:19" (month / day / year: minutes: seconds)

2 、 hwclock/clock

View hardware time

# hwclock-show

Or # clock-show

Set hardware time

# hwclock-set-date= "07swap 07max 06 10:19" (month / day / year: minutes: seconds)

Or # clock-set-date= "07swap 07max 06 10:19" (month / day / year: minutes: seconds)

3. Synchronization of hardware time and system time

According to the previous statement, when you restart the system, the hardware time reads the system time to achieve synchronization, but when you do not restart, you need to use the hwclock or clock command to achieve synchronization.

Hardware clock synchronizes with system clock: # hwclock-hctosys (hc represents hardware time, sys represents system time) or # clock-hctosys

System clock and hardware clock synchronization: # hwclock-systohc or # clock-systohc

3. Time zone TZ setting in UNIX

How to modify the time zone:

Solaris:

In solaris, you need to modify the / etc/TIMEZONE file to modify the time zone, where TZ=PRC represents the Chinese time zone. We can replace it with TZ=US/Pacific, restart the machine, and change the time zone to the US Pacific time zone.

There are three points to note here:

1. On the X86 machine, you need to update the / etc/rtc_config file by executing the following command:

# rtc-z zone-name (here zone-name is the value of TZ in / etc/TIMEZONE)

# rtc-c

2, how many mid-time zones can you choose from? We can go to the / usr/share/lib/zoneinfo directory, where there are many directories, including US, and there are also many files, such as PRC;, which means that there are many time zones under US, and PRC is the same time zone. Because of this, we see two different forms of TZ=PRC and TZ=US/Pacific.

3. The system needs to be restarted for it to take effect.

AIX:

1. View the current time zone (other operating systems are date commands)

Cat / etc/environment (find the line of TZ)

2. For the sake of appropriateness, it is recommended to use smit to modify the time zone

Smit chtz

3. All the time zone information is in the / usr/share/lib/zoneinfo directory

HPUX:

Modify the configuration file, / etc/TIMEZONE is

# vi / etc/TIMEZONETZ=EAT-8export TZ

Modify the configuration file / etc/default/tz to

# vi / etc/default/tz EAT-8

The system needs to be restarted after the modification is completed.

# echo $TZ

EAT-8

(if APP shows UTC time, you need to subtract 8 hours to convert to local Beijing time. )

4. Common definition of system time zone:

Time Zones Defined on the System:Name Time Zone CUT OffsetCUT0GDT Coordinated Universal Time CUTGMT0BST United Kingdom CUTAZOREST1AZOREDT Azores, Cape Verde CUT-1FALKST2FALKDT Falkland Islands CUT-2GRNLNDST3GRNLNDDT Greenland East Brazil CUT-3AST4ADT Central Brazil CUT-4 English: system time zone definition time zone definition GMT time definition CUT0GDT Greenwich mean time CUTGMT0BST London Lisbon Edinburgh CUTAZOREST1AZOREDT Azores Cape Verde Islands CUT-1FALKST2FALKDT Falkland Islands (West Atlantic) CUT-2GRNLNDST3GRNLNDDT Greenland Brasilia Newfoundland CUT-3AST4ADT Atlantic time (Canada) Western South America San Diego CUT-4EST5EDT Eastern time (US and Canada) Indiana (East) CUT-5CST6CDT Central time (US and Canada) Mexico City CUT-6MST7MDT Mountain time (US and Canada) Arizona CUT-7PST8PDT Pacific time (US and Canada) Tijuana CUT-8AST9ADT Alaska CUT-9HST10HDT Hawaii CUT-10BST11BDT Midway Island Samoa CUT-11NZST-12NZDT New Zealand (Pacific Southern Island) CUT + 12PAKST-5PAKDT Islamabad Karachi CUT + 5WST-4WDT Gorky Central Asia Oman CUT + 4MEST-3MEDT Turkey CUT + 3SAUST-3SAUDT Saudi Arabia CUT + 3WET-2WET Finland CUT + 2USAST-2USADT Eastern Europe CUT + 2NFT-1DFT Norway (Nordic countries) Rome CUT + 1

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report