2017年1月3日 星期二

[Linux 常見問題] How To Change Timezone on a CentOS 6 and 7

Source From Here
Question
I set my time zone to ‘America/New_York’ on a CentOS Linux 7 server. I want to see date and time in my timezone in log files. How can I change the current timezone from ‘America/New_York’ to ‘America/Chicago’ using command line?

How-To
You can easily change timezone in CentOS Linux using the following methods.

CentOS timezone config files and directories
- /usr/share/zoneinfo/
The system timezone directory contains the files as per timezone name. For example, the file /usr/share/zoneinfo/America/New_York represents time zone for New York.

- /etc/localtime
It is a symlink to the file localtime or to the correct timezone file in the system located in /usr/share/zoneinfo/ directory.


How do I see the current time zone?
Type the date command or the ls command:
# date
Tue Jan 3 16:31:42 CST 2017
# ls -hl /etc/localtime
lrwxrwxrwx. 1 root root 33 Jan 2 21:55 /etc/localtime -> ../usr/share/zoneinfo/Asia/Taipei

Change the current timezone in CentOS 7
To find list of all available time zones, run:
# timedatectl list-timezones | grep Asia // Check supported Asia timezone
# timedatectl set-timezone America/Chicago // set timezone to America/Chicago
# ls -l /etc/localtime // Verify new settings

Change the current timezone in CentOS 6 and older
# cp /etc/localtime /root/old.timezone
# rm /etc/localtime
# ln -s /usr/share/zoneinfo/America/Chicago /etc/localtime
# ls -l /etc/localtime // Verify new settings


沒有留言:

張貼留言

[ Python 文章收集 ] cmd – Create line-oriented command processors

Source From  Here   Preface   The  cmd  module contains one public class,  Cmd , designed to be used as a base class for command processors ...