Time Management for Linux systems

Source: Internet
Author: User
Tags time and date

Time Management for Linux systems

1 Viewing system time and date: date

[Email protected] desktop]# date Tue June 2 05:25:05 EDT 2015


2 View hardware time: Hwclock--show | -R

[Email protected] desktop]# hwclock Tue 05:40:30 AM EDT-0.272377 seconds


3 Modify the command used by the system time:

To modify the system time:

[[email protected] named]# date-s "6/1/2015 18:00:00" #设置为6月/1st/2015 year: minute: Mon June 1 18:00:00 EDT 2015[[email protected] named]# date-s "11:11:11 2011-10-3" #这样也行Mon Oct 3 11:11:11 CST 2011

To modify the system hardware time:

[Email protected] desktop]# hwclock--set--date= "06/18/14 14:55" [[email protected] desktop]# Hwclock-r # #相当于hwclock --showwed June 02:55:22 PM EDT-0.569262 seconds

4 Write the time and date of the current system to the BIOS to avoid failure after reboot: Hwclock-w

[Email protected] desktop]# hwclock-w

Attention:

Hwclock

# #将系统时间设置为当前硬件的时间

-S,--hctosys set the system time from the hardware clock

# #将硬件的时间设置为当前系统的时间

-W,--SYSTOHC set the hardware clock from the current system time


5 time zone changes: tzselect

Tzselect just prompts us to choose the time zone, which will not actually take effect, but we can follow the instructions.

[[Email protected] desktop]# tzselect please identify a location so  that time zone rules can be set correctly. please select a continent or ocean. 1)  africa 2)  Americas 3)  antarctica 4)  arctic ocean 5)  asia 6)  atlantic ocean 7)  australia 8)  europe 9)  indian ocean10)  pacific ocean11)  none  - i want to specify the time zone using the posix  tz format.#? 5please select a country. 1)  Afghanistan  18)  israel    35) ( palestine 2)  armenia  19)  Japan     36) ( philippines 3)  azerbaijan  20)  Jordan     37)  qatar 4)  bahrain  21) &nbsP kazakhstan    38)  russia 5)  bangladesh  22)  Korea  ( North)     39)  saudi arabia 6)  bhutan  23)  Korea  ( South)     40)  singapore 7)  brunei  24)  Kuwait     41) ( sri lanka 8)  cambodia  25)  Kyrgyzstan     42)  syria 9)  china  26)  laos    43)  Taiwan10)  cyprus  27)  lebanon    44)  tajikistan11)  East Timor   28) ( macau    45)  thailand12)  georgia  29)   malaysia    46)  turkmenistan13)  hong kong  30)  Mongolia     47)  united arab emirates14)  india  31)  Myanmar   (Burma)     48) &nbSp UZBEKISTAN15)  indonesia  32)  nepal    49)  vietnam16)  Iran   33)  oman    50)  yemen17)  iraq  34)  Pakistan#?  9please select one of the following time zone regions.1)   EAST CHINA - BEIJING, GUANGDONG, SHANGHAI, ETC.2)  Heilongjiang  (except  mohe),  jilin3)  central china - sichuan, yunnan, guangxi, shaanxi ,  guizhou, etc.4)  most of tibet & xinjiang5)  west Tibet  & Xinjiang#? 1The following information has been given:Chinaeast  China - beijing, guangdong, shanghai, etc. therefore tz= ' Asia/shanghai '  will be used. local time is now:wed jun  3 09:31:59 cst 2015.universal time is now:wed jun  3 01:31:59 utc 2015.is the above  information ok?1)  yes2)  no#? 1   # #以下是一个实际生效的提示You  can make  This change permanent for yourself by appending the linetz= ' Asia/ Shanghai '; export tzto the file  '. Profile '  in your home directory ;  then log out and log in again. Here is that tz value again, this time on standard output  so that youcan use the /usr/bin/tzselect command in shell  Scripts:asia/shanghai

According to the following hints, it is necessary to tz= ' Asia/shanghai '; Export TZ This line is written to the. Profile configuration file, but I'm used to writing it in the. bashrc file.

[Email protected] ~]# vim/root/.bash_profile # #编辑当前用户的bash环境文件 [[email protected] ~]# cat/root/.bash_profile#. bash_ profile# Get the aliases and Functionsif [-f ~/.BASHRC]; Then. ~/.bashrcfi# User specific environment and startup Programspath= $PATH: $HOME/binexport pathtz= ' Asia/shanghai '; Export TZ # #将时区更改的语句 put it here.

It is recommended that you write the time zone setting in the/ETC/BASHRC file, which takes effect globally.


To view the current time zone:

[Email protected] desktop]# date-rtue, 2015 22:09:31-0400

Refresh and reread. Bash_profile

[Email protected] desktop]# date-rtue, June 22:14:49-0400[[email protected] desktop]# source/root/.bash_profile [Email protected] desktop]# date-r

Wed, June 10:15:10 +0800 # #时区已更改为北京时区


Another way: Modify the configuration file directly

Configuration file for time zone:/etc/localtime

Storage path for all time zone files:/usr/share/zoneinfo

Asia Time zone:/usr/share/zoneinfo/asia

Choose Shanghai time Zone:/usr/share/zoneinfo/asia/shanghai

Link the Shanghai time zone file software to the time zone configuration file/etc/localtime

[Email protected]/]# ln-s/usr/share/zoneinfo/asi a/shanghai/etc/localtime

View Date-r after reboot



Graphical interface:

Redhat 6 or less: System-config-time

Redhat 7:system-config-date



This article is from the "Tiandaochouqin" blog, make sure to keep this source http://luzhi1024.blog.51cto.com/8845546/1657804

Time Management for Linux systems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.