Change Timezone in CentOS image

 

If you use CentOS VPS, displaying the correct time zone can be an issue. If you type “date” into the SSH terminal, the date and time displayed are likely incorrect. Remember, CentOS uses the file /etc./localtime to decide the appropriate time zone to display without ever asking the user.

 

Step 1: Out With the Old

If you enter “date” into the SSH terminal and an incorrect time or date is returned, then you should first delete the incorrect file. Use the function “mv /etc/localtime /etc/localtime.bak” to complete this. CentOS will no longer be using a proper localtime file. At this point you can run the date command once more and this time you will see a universal time.

 

Step 2: In With the New

The next step is to populate a new /etc/localtime file with correct time and date information. Instead of creating a whole new file, you can create a symlink to an existing time zone file, which will be located in /usr/share/zoneinfo. Find the appropriate file in this directory.

 

A Quick & Easy Example

We are located in Houston, Texas, which is in the Central time zone (CST). That means that a user in our office would select the file /usr/share/zoneinfo/America/Chicago to update his/her server to the correct time zone. To link these, enter the following command:

 

In –s /usr/share/zoneinfo/America/Chicago /etc/localtime

 

Run the date command one final time to verify that your time zone is correct. Now you no longer have to live with an incorrect time being displayed in your CentOS VPS!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>