2007/May/11

ในบางครั้งที่มีการติดตั้ง Server ด้วย linux แล้ว หากเราเลือก timezone ของระบบผิด จะทำให้ระบบแสดงเวลาไม่ถูกต้อง และมีผลต่อ web ที่ต้องนำข้อมูลวันที่มาแสดง
เราจะมาดูวิธีการกำหนดกันนะครับ
สำหรับ Ubuntu สามารถใช้ เครื่องมือที่มีอยู่ด้วยคำสั่งนี้ครับ
tzconfig
เมื่อพิมพ์แล้วจะแสดงข้อมูลต่อไปนี้
Your current time zone is set to Asia/Bangkok <---- ตรงนี้หากเป็น zone อื่นจะแสดง
Do you want to change that? [n]: y

Please enter the number of the geographic area in which you live:


1) Africa 7) Australia

2) America 8) Europe

3) US time zones 9) Indian Ocean

4) Canada time zones 10) Pacific Ocean

5) Asia 11) Use System V style time zones

6) Atlantic Ocean 12) None of the above


Then you will be shown a list of cities which represent the time zone
in which they are located. You should choose a city in your time zone.

Number: 5

Aden Almaty Amman Anadyr Aqtau Aqtobe Ashgabat Ashkhabad Baghdad Bahrain
Baku Bangkok Beirut Bishkek Brunei Calcutta Choibalsan Chongqing Chungking
Colombo Dacca Damascus Dhaka Dili Dubai Dushanbe Gaza Harbin Hong_Kong
Hovd Irkutsk Istanbul Jakarta Jayapura Jerusalem Kabul Kamchatka Karachi
Kashgar Katmandu Krasnoyarsk Kuala_Lumpur Kuching Kuwait Macao Macau
Magadan Makassar Manila Muscat Nicosia Novosibirsk Omsk Oral Phnom_Penh
Pontianak Pyongyang Qatar Qyzylorda Rangoon Riyadh Riyadh87 Riyadh88
Riyadh89 Saigon Sakhalin Samarkand Seoul Shanghai Singapore Taipei
Tashkent Tbilisi Tehran Tel_Aviv Thimbu Thimphu Tokyo Ujung_Pandang
Ulaanbaatar Ulan_Bator Urumqi Vientiane Vladivostok Yakutsk Yekaterinburg
Yerevan

Please enter the name of one of these cities or zones
You just need to type enough letters to resolve ambiguities
Press Enter to view all of them again
Name: [] Bangkok
Your default time zone is set to 'Asia/Bangkok'.
Local time is now: Fri May 11 10:55:17 ICT 2007.
Universal Time is now: Fri May 11 03:55:17 UTC 2007.

ทำตามขั้นตอนเหล่านี้ก็จะเปลี่ยน Timezone ได้แล้วครับ
และมีอีกวิธีหนึ่งครับ อันนี้เขาบอกว่าใช้กับ Linux ทั่วไป อย่างไรก็ทดลองดูกันนะครับ
ขั้นตอนมีดังนี้ครับ
  1. Logged in as root, check which timezone your machine is currently using by executing `date`. You'll see something like "Mon 17 Jan 2005 12:15:08 PM PST -0.461203 seconds", PST in this case is the current timezone.
  2. Change to the directory to /usr/share/zoneinfo, here you will find a list of time zone regions. Choose the most appropriate region, if you live in Canada or the US this directory is the "Americas" directory.
  3. If you wish, backup the previous timezone configuration by copying it to a different location. Such as `mv /etc/localtime /etc/localtime-old`. <-- เริ่มที่ตรงนี้เลย
  4. Create a symbolic link fr om the appropiate timezone to /etc/localtime. Example: `ln -s /usr/share/zoneinfo/Europe/Amsterdam /etc/localtime`.
    ของไทยก็ ln -s /usr/share/zoneinfo/Asia/Bangkok /etc/localtime
  5. If you have the utility rdate, update the current system time by executing `/usr/bin/rdate -s time.nist.gov`.
  6. Set the ZONE entry in the file /etc/sysconfig/clock file (e.g. "America/Los_Angeles")
  7. Set the hardware clock by executing: ` /sbin/hwclock --systohc`
แค่นี้ก็จะเปลี่ยน timezone ได้แล้ว และเขาบอกว่าวิธีนี้สามารถใช้กับ RedHat Linux, Slackware, Gentoo, SuSE, Debian, Ubuntu ครับ
และนี้เป็นส่วนต่อท้ายที่บอกว่าอะไรทำได้แบบใดครับ

Tips

  • On some versions of RedHat Linux, Slackware, Gentoo, SuSE, Debian, Ubuntu, and anything else that is "normal", the command to display and change the time is 'date', not 'clock'
  • On RedHat Linux there is a utility called "Setup" that allows one to select the timezone from a list, but you must have installed the 'redhat-config-date' package.


Warnings

  • Some applications (such as PHP) have separate timezone settings from the system timezone.
  • On some systems, there is a system utility provided that will prompt for the correct timezone and make the proper changes to the system configuration. For example, Debian provides the "tzsetup" ot "tzconfig" utility.
ที่มาครับ http://www.wikihow.com/Change-the-Timezone-in-Linux
ขอให้สนุกกับ Linux


ชื่อ: 
เว็บไซต์: 
คอมเมนต์:




smilebig smileopen-mounthed smileconfused smilesad smileangry smiletonguequestionembarrassedsurprised smilewinkdouble winkcry

<< Home