Introduction
You may use the following procedure to change the timezone of a CentOS server.
CentOS 7
1. Login to the server via SSH or Terminal as the root user
2. First verify what the current settings are by issuing the following command:
timedatectl
3. List which timezones are available to use, and find the exact format that you'll use in the next command:
timedatectl list-timezones
4. Next set the timezone to one from the above list. This example uses UTC which is recommended for all servers around the world to make administering multiple systems easier:
timedatectl set-timezone UTC
5. Verify that the timezone has updated with the following commands:
timedatectl
date
CentOS 6 and Older
1. Login to the server via SSH or Terminal as the root user
2. Verify the existing configuration:
date
stat /etc/localtime
The /etc/localtime file will often be a symlink to a timezone file. Sometimes this will just be a regular file so the stat command may not prove to be useful to show what timezone is in use. The date command should work fine to verify the current timezone in use though. Verifying which timezone is currently in use is recommended just so that you are able to verify that the following changes you make actually did something.
3. Print the list of timezones available to use with the following command:
find /usr/share/zoneinfo/ -type f | less
4. Copy the path of your desired timezone and then press q to exit the less pager
5. Move the existing timezone file out of the way:
mv -v /etc/localtime /root/localtime.removeMeWhenDone
6. Create a symlink to the timezone file that you copied earlier. This example uses UTC which is the recommended timezone for all servers around the world to make it easier when administering multiple systems:
ln -s /usr/share/zoneinfo/UTC /etc/localtime
7. Verify that the timezone has been updated:
date
Comments
0 comments
Article is closed for comments.