ºìÁªLinuxÃÅ»§
Linux°ïÖú

Linuxʱ¼äÉèÖÃÃüÁî

·¢²¼Ê±¼ä:2012-05-04 10:13:52À´Ô´:ºìÁª×÷Õß:empast
1¡¢date:
Óï·¨¸ñʽ£ºdate [-u] [-d datestr] [-s datestr] [--utc] [--universal] [--date=datestr] [--set=datestr] [--help] [--version] [+FORMAT] [MMDDhhmm[[CC]YY][.ss]]
˵Ã÷£º¿ÉÓÃÀ´ÉèÖÃϵͳÈÕÆÚÓëʱ¼ä¡£Ö»ÓйÜÀíÔ±²ÅÓÐÉèÖÃÈÕÆÚÓëʱ¼äµÄȨÏÞ£¬Ò»°ãÓû§Ö»ÄÜÓÃdate ÃüÁîÏÔʾʱ¼ä¡£Èô²»¼ÓÈκβÎÊý£¬data »áÏÔʾĿǰµÄÈÕÆÚÓëʱ¼ä¡£
Àý1£ºÏÔʾµ±Ç°ÏµÍ³Ê±¼ä
[root@Test2 ~]# date
2010 Äê06 ÔÂ17 ÈÕÐÇÆÚËÄ00:00:04 CST
Àý2£ºÉèÖÃÈÕÆÚºÍʱ¼äΪ2010 Äê6 ÔÂ18 ºÅ12:00
[root@Test2 ~]# date -s "20100618 12:00:00"
2010 Äê06 ÔÂ18 ÈÕÐÇÆÚÎå12:00:00 CST
Àý3£ºÉèÖÃÈÕÆÚΪ2010ÄêÄê6 ÔÂ18 ºÅ
[root@Test2 ~]# date -s 20100618
2010 Äê06 ÔÂ18 ÈÕÐÇÆÚÎå00:00:00 CST
Àý4£ºÉèÖÃʱ¼äΪ12:00:00
[root@Test2 ~]# date 12:00:00
date: invalid date ¡°12:00:00¡±
Àý5£ºÏÔʾʱÇø
[root@Test2 ~]# date -R
Thu, 17 Jun 2010 00:01:36 +0800
»òÕߣº
[root@Test2 ~]# cat /etc/sysconfig/clock
# The ZONE parameter is only evaluated by system-config-date.
# The timezone of the system is defined by the contents of /etc/localtime.
ZONE="Asia/Shanghai"
UTC=true
ARC=false

2¡¢hwclock/clock
Óï·¨¸ñʽ£ºhwclock [--adjust][--debug][--directisa][--hctosys][--show][--systohc][--test] [--utc][--version][--set --date=<ÈÕÆÚÓëʱ¼ä>]
²ÎÊý£º
--adjust hwclock ÿ´Î¸ü¸ÄÓ²¼þʱÖÓʱ£¬¶¼»á¼Ç¼ÔÚ/etc/adjtime ÎļþÖС£Ê¹ÓÃ--adjust ²ÎÊý£¬¿Éʹhwclock¸ù¾ÝÏÈÇ°µÄ¼Ç¼À´¹ÀËãÓ²¼þʱÖÓµÄÆ«²î£¬²¢ÓÃÀ´Ð£ÕýÄ¿Ç°µÄÓ²¼þʱÖÓ¡£
--debug ÏÔʾhwclock Ö´ÐÐʱÏêϸµÄÐÅÏ¢¡£
--directisa hwclock Ô¤Éè´Ó/dev/rtc É豸À´´æÈ¡Ó²¼þʱÖÓ¡£ÈôÎÞ·¨´æȡʱ£¬¿ÉÓô˲ÎÊýÖ±½ÓÒÔI/O Ö¸ÁîÀ´´æÈ¡Ó²¼þʱÖÓ¡£
--hctosys ½«ÏµÍ³Ê±ÖÓµ÷ÕûΪÓëÄ¿Ç°µÄÓ²¼þʱÖÓÒ»Ö¡£
--set --date=<ÈÕÆÚÓëʱ¼ä> É趨Ӳ¼þʱÖÓ¡£
--show ÏÔʾӲ¼þʱÖÓµÄʱ¼äÓëÈÕÆÚ¡£
--systohc ½«Ó²¼þʱÖÓµ÷ÕûΪÓëÄ¿Ç°µÄϵͳʱÖÓÒ»Ö¡£
--test ½ö²âÊÔ³ÌÐò£¬¶ø²»»áʵ¼Ê¸ü¸ÄÓ²¼þʱÖÓ¡£
--utc ÈôҪʹÓøñÁÖÍþÖÎʱ¼ä£¬Çë¼ÓÈë´Ë²ÎÊý£¬hwclock »áÖ´ÐÐת»»µÄ¹¤×÷¡£
--version ÏÔʾ°æ±¾ÐÅÏ¢¡£
Àý1£º²é¿´Ó²¼þʱ¼ä
# hwclock --show
»òÕß
# clock --show
Àý2£ºÉèÖÃÓ²¼þʱ¼ä
# hwclock --set --date="07/07/06 10:19" £¨ÔÂ/ÈÕ/Äêʱ:·Ö:Ã룩
»òÕß
# clock --set --date="07/07/06 10:19" £¨ÔÂ/ÈÕ/Äêʱ:·Ö:Ã룩
Àý3£ºÓ²¼þʱ¼äºÍϵͳʱ¼äµÄͬ²½
°´ÕÕÇ°ÃæµÄ˵·¨£¬ÖØÐÂÆô¶¯ÏµÍ³£¬Ó²¼þʱ¼ä»á¶Áȡϵͳʱ¼ä£¬ÊµÏÖͬ²½£¬µ«ÊÇÔÚ²»ÖØÐÂÆô¶¯µÄʱºò£¬ÐèÒªÓÃhwclock »òclock ÃüÁîʵÏÖͬ²½¡£
Ó²¼þʱÖÓÓëϵͳʱÖÓͬ²½£º
# hwclock --hctosys£¨hc ´ú±íÓ²¼þʱ¼ä£¬sys ´ú±íϵͳʱ¼ä£©
»òÕß
# clock -hctosys
Àý4£ºÏµÍ³Ê±ÖÓºÍÓ²¼þʱÖÓͬ²½£º
# hwclock --systohc
»òÕß
# clock -systohc
Àý5£ºÇ¿Öƽ«ÏµÍ³Ê±¼äдÈëCMOS£¬Ê¹Ö®ÓÀ¾ÃÉúЧ£¬±ÜÃâϵͳÖØÆôºó»Ö¸´³Éԭʱ¼ä
# clock -w
»òÕß
# hwclock -w

3¡¢Ê±ÇøµÄÉèÖÃ
# 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 Ocean
10) Pacific Ocean
11) none - I want to specify the time zone using the Posix TZ format.
#? ÊäÈë5£¬ÑÇÖÞ
Please select a country.
1) Afghanistan 18) Israel 35) Palestine
2) Armenia 19) Japan 36) Philippines
3) Azerbaijan 20) Jordan 37) Qatar
4) Bahrain 21) 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) Taiwan
10) Cyprus 27) Lebanon 44) Tajikistan
11) East Timor 28) Macau 45) Thailand
12) Georgia 29) Malaysia 46) Turkmenistan
13) Hong Kong 30) Mongolia 47) United Arab Emirates
14) India 31) Myanmar (Burma) 48) Uzbekistan
15) Indonesia 32) Nepal 49) Vietnam
16) Iran 33) Oman 50) Yemen
17) Iraq 34) Pakistan
#? ÊäÈë9£¬Öйú
Please select one of the following time zone regions.
1) east China - Beijing, Guangdong, Shanghai, etc.
2) Heilongjiang
3) central China - Gansu, Guizhou, Sichuan, Yunnan, etc.
4) Tibet & most of Xinjiang Uyghur
5) southwest Xinjiang Uyghur
#? ÊäÈë1£¬±±¾©Ê±¼ä
The following information has been given:
China
east China - Beijing, Guangdong, Shanghai, etc.
Therefore 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) Yes
2) No
#? ÊäÈë1£¬È·ÈÏ
Èç¹û²»ÓÃtzselect ÃüÁ¿ÉÒÔÐÞ¸ÄÎļþ±ä¸üʱÇø¡£
# vi /etc/sysconfig/clock
Z/Shanghai£¨²é/usr/share/zoneinfo ÏÂÃæµÄÎļþ£©
UTC=false
ARC=false
# rm /etc/localtime
# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
ÖØÐÂÆô¶¯¼´¿É¡£

4¡¢Í¼ÐνçÃæÉèÖÃʱÇøÃüÁîtimeconfig

5¡¢Ê±¼äͬ²½
Àý1£ºÍ¬²½Ê±¼ä
# ntpdate 210.72.145.44 £¨210.72.145.44 ÊÇÖйú¹ú¼ÒÊÚʱÖÐÐĵĹٷ½·þÎñÆ÷£©
Àý2£º¶¨Ê±Í¬²½Ê±¼ä
# crontab -e Ìí¼Ó½Å±¾Àý×ÓÈçÏ£º
*/20 * * * * /usr/sbin/ntpdate 210.72.145.44 //ÿ20 ·ÖÖÓÖ´ÐÐÒ»´Î
30 5 * * * /usr/sbin/ntpdate 210.72.145.44 //ÿÌìÔ糿5 µã°ëÖ´ÐÐ
¡ù Ç°ÃæÎå¸ö*ºÅ´ú±íÎå¸öÊý×Ö£¬Êý×ÖµÄÈ¡Öµ·¶Î§ºÍº¬ÒåÈçÏ£º·ÖÖÓ£¨0-59£© С?£¨0-23£© ÈÕÆÚ£¨1-31£© Ô·ݣ¨1-12£© ÐÇÆÚ£¨0-6£©//0 ´ú±íÐÇÆÚÌìÉ趨Íê±Ïºó£¬¿ÉʹÓÃ# crontab -l ²é¿´ÉÏÃæµÄÉ趨¡£
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 1 ÌõÆÀÂÛ

  1. ËÕÎÄÁú ÓÚ 2012-07-20 16:53:06·¢±í:

    you did a very good job .!!!