Linux TimeZone设置
来源:互联网 发布:微博淘宝客 编辑:程序博客网 时间:2024/06/05 09:34
最近遇到一个有关timezone的问题:有些application需要环境变量TZ,可是我们刚刚装好的RHEL没有设置TZ,而我又没有root权限去改,查了半天资料,发现所有对timezone的改动都需要重启机器才能生效,没有办法即时生效……Anyway,还是把查到的资料罗列在下面,以备将来用到。
- Linux Clock Configuration
- Howto: Linux server change or setup the timezone
原文:http://www.linuxselfhelp.com/quick/clock.html
Author: Edward Buck This guide will help you setup the correct date and time on your Red Hat 7.x Linux system including setting up ntpd for online time synchronization. There are two clocks to configure in Linux, the hardware clock and the system clock. The hardware clock determines the system clock on system boot. While the system is running, changes to one of these doesn't affect the other. Note: it's best to set the hardware clock and have the system clock be set upon a reboot. Changing the system clock by using the date program on a running system could cause date discontinuities and consequently problems. If you will be using ntpd, you probably don't need to set either of these clocks (unless the current time is more than 1000s off the real time). Just setup ntpd and let ntpd adjust the time (it will do it in small steps to keep system timestamps reliable). Linux Clock Configuration
Version: .2
Last edited: December 19, 2002Summary
Instructions
If using the dateconfig tool is not an option, follow the remaining steps to configure manually. For example, if you are using a non graphical terminal (dateconfig requires X windows), you must configure manually.
Linux uses the file /etc/localtime to determine the time zone. This file should be either a copy of the appropriate timezone file from the directory /usr/share/zoneinfo or a symbolic link. If your time zone is incorrect, create a symbolic link to the appropriate timezone file.# ln -s /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
Edit the file /etc/sysconfig/clock and change "UTC=" to true or false. If you have a dual-boot system with Windows, using UTC may cause problems for Windows.# date MMDDhhmmCCYY.ss
where MM is month, DD is day, hh is hour, mm is minutes, CCYY is year and ss is seconds. Time should be in 24-hour notation.
To only set the time: # date -s hh:mm:ss
To set the hardware clock to the current system clock: # setclock
this method looks at /etc/sysconfig/clock to determine whether the hardware clock is set to UTC
Another method: # hwclock --systohc
use the second option if you use UTC.
# hwclock --systohc --utc
Set hwclock manually: # hwclock --set --date="9/22/96 16:45:05"
Everytime you use the hwclock --set command, it will create or edit the file /etc/adjtime to determine the systematic drift. Once you have some history, you can use the --adjust option to adjust the hardware clock appropriately. Run as a cron job if you want the clock to adjust automatically on a regular schedule. Don't use the --adjust function when using ntpd since ntpd will turn the "11 minute mode" on, which is best left alone. See the hwclock manpage for more info.
Run Red Hat's setup utility to make ntpd start on boot up and edit /etc/ntp.conf
Set server and fudge options:server time.nist.gov
Enable multicastclient:
fudge time.nist.gov stratum 10multicastclient # listen on default 224.0.1.1
Edit /etc/sysconfig/ntpd if necessary. The default should be fine.
Start the ntpd daemon:# service ntpd start
原文:http://www.cyberciti.biz/faq/howto-linux-unix-change-setup-timezone-tz-variable/
Q. My timezone is pointing to wrong timezone. How do I setup or change the timezone under Linux operating systems? The definition for time zones can be written in short form as UTC±n (or GMT±n), where n is the offset in hours. Select the method as per your Linux distribution: Type the redhat-config-date command at the command line to start the time and date properties tool. Select timezone configuration Now, just follow on screen instructions to change timezone. Often /etc/localtime is a symlink to the file localtime or to the correct time zone file in the system time zone directory. Change directory to /etc Create a symlink to file localtime: Use date command to verify that your timezone is changed: You can use TZ environment variable to display date and time according to your timezone:Howto: Linux server change or setup the timezone
A. Unix time, or POSIX time, is a system for describing points in time: it is the number of seconds elapsed since midnight UTC on the morning of January 1, 1970, not counting leap seconds.Change Linux timezone
If you are using Fedora / RHEL / Cent OS Linux
# redhat-config-date
OR type setup and select time zone configuration (good for remote ssh text based Linux server sessiob)# setup
Set timezone using /etc/localtime configuration file [any Linux distro]
Generic procedure to change timezone
# cd /etc
# ln -sf /usr/share/zoneinfo/EST localtime
OR some distro use /usr/share/zoneinfo/dirname/zonefile format (Red hat and friends)# ln -sf /usr/share/zoneinfo/EST localtime
OR if you want to set up it to IST (Asia/Calcutta):# ln -sf /usr/share/zoneinfo/Asia/Calcutta localtime
Please mote that in above example you need to use directory structure i.e. if you want to set the timezone to Calcutta (India) which is located in the Asia directory you will then have to setup using as above.$ date
Output:Tue Aug 27 14:46:08 EST 2006
Use of environment variable
$ export TZ=America/Los_Angeles
$ date
Sample Output:Thu Aug 27 11:10:08 PST 2006
- Linux TimeZone设置
- 嵌入式Linux系统如何设置TimeZone
- 【ERROR_1】设置timezone
- postgresql.conf timezone 设置
- 设置时区TimeZone
- Lumen 设置 timezone 时区
- Laravel设置timezone时区
- Java TimeZone 和 Linux TimeZone问题
- linux date timezone
- linux date timezone
- EBS:Timezone Conversions的设置
- Tornado设置数据库的Timezone
- xen 虚拟机 linux timezone 错误
- TimeZone
- Timezone
- timezone
- TimeZone
- timezone
- 一些提升你jquery效率的小技巧
- 做一个成功的交谈者
- C#事务死锁的原因
- Apache java项目全介绍
- 客户端连接服务器,配置出错“连接超时”或者“无监听程序”解决方法
- Linux TimeZone设置
- Ubuntu 10.10启动进入命令行模式
- 网站开发常用(转载)
- PHP ZIP解压缩
- 在.NET使用JSON作为数据交换格式
- [转载]关于驱动中的ObReferenceObjectByName 和 IoGetDeviceObjectPointer
- Sql Server 中日期格式化函数
- Oracle Net Manager 的使用方法(监听的配置方法)
- 备忘之数据库