It’s About Time

So I’ve been off my game for a while. Work’s been crazy and it seems like I surprisingly lost steam after my trip to SELF. Go figure. Regardless, let’s get back into the study game. On tap today is managing the time settings on your RHEL server.

Your timezone information is detailed at /etc/localtime. However, this is really just a symlink to the actual info as shown here:

lrwxrwxrwx. 1 root root 38 Sep  2 15:11 /etc/localtime -> ../usr/share/zoneinfo/America/New_York

The timedatectl utility can be used not only to display your current settings (timezone, NTP, etc.) but also to make adjustments.

# timedatectl
      Local time: Thu 2016-09-15 20:32:33 EDT
  Universal time: Fri 2016-09-16 00:32:33 UTC
        RTC time: Fri 2016-09-16 00:32:32
       Time zone: America/New_York (EDT, -0400)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: yes
 Last DST change: DST began at
                  Sun 2016-03-13 01:59:59 EST
                  Sun 2016-03-13 03:00:00 EDT
 Next DST change: DST ends (the clock jumps one hour backwards) at
                  Sun 2016-11-06 01:59:59 EDT
                  Sun 2016-11-06 01:00:00 EST

Changing Your Timezone
There are a couple of ways you can change your timezone. If you know your timezone you can use the timedatectrl utility directly. If you’re not sure, you can get a listing of available timezones by running:

timedatectl list-timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
.....
America/Nassau
America/New_York
America/Nipigon
America/Nome
America/Noronha
America/North_Dakota/Beulah
America/North_Dakota/Center
America/North_Dakota/New_Salem

Since I’m on the US East coast my timezone is “America/New_York”. Just pass the timezone to the utility with the set-timezone function:

timedatectl set-timezone America/New_York

If you don’t remember how to use the utility, there is an easy way to walk through a “wizard” using the tzselect utility. Simply answer the questions and your timezone will be updated correctly.

Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.
 1) Africa
 2) Americas
 3) Antarctica
 4) Arctic Ocean
 5) Asia
 6) Atlantic Ocean
 7) Australia
 8) Europe
 9) Indian Ocean
10) Pacific Ocean
11) none - I want to specify the time zone using the Posix TZ format.
 
#? 2
Please select a country.
 1) Anguilla   		  19) Dominican Republic    37) Peru
 2) Antigua & Barbuda  	  20) Ecuador  		    38) Puerto Rico
 3) Argentina  		  21) El Salvador      	    39) St Barthelemy
 4) Aruba      		  22) French Guiana    	    40) St Kitts & Nevis
 5) Bahamas    		  23) Greenland		    41) St Lucia
 6) Barbados   		  24) Grenada  		    42) St Maarten (Dutch)
 7) Belize     		  25) Guadeloupe       	    43) St Martin (French)
 8) Bolivia    		  26) Guatemala		    44) St Pierre & Miquelon
 9) Brazil     		  27) Guyana   		    45) St Vincent
10) Canada     		  28) Haiti    		    46) Suriname
11) Caribbean NL       	  29) Honduras 		    47) Trinidad & Tobago
12) Cayman Islands     	  30) Jamaica  		    48) Turks & Caicos Is
13) Chile      		  31) Martinique       	    49) United States
14) Colombia   		  32) Mexico   		    50) Uruguay
15) Costa Rica 		  33) Montserrat       	    51) Venezuela
16) Cuba       		  34) Nicaragua		    52) Virgin Islands (UK)
17) Curacao    		  35) Panama   		    53) Virgin Islands (US)
18) Dominica   		  36) Paraguay
 
#? 49
Please select one of the following time zone regions.
 1) Eastern (most areas)       	      16) Central - ND (Morton rural)
 2) Eastern - MI (most areas)  	      17) Central - ND (Mercer)
 3) Eastern - KY (Louisville area)    18) Mountain (most areas)
 4) Eastern - KY (Wayne)       	      19) Mountain - ID (south); OR (east)
 5) Eastern - IN (most areas)  	      20) MST - Arizona (except Navajo)
 6) Eastern - IN (Da, Du, K, Mn)      21) Pacific
 7) Eastern - IN (Pulaski)     	      22) Alaska (most areas)
 8) Eastern - IN (Crawford)    	      23) Alaska - Juneau area
 9) Eastern - IN (Pike)		      24) Alaska - Sitka area
10) Eastern - IN (Switzerland) 	      25) Alaska - Annette Island
11) Central (most areas)       	      26) Alaska - Yakutat
12) Central - IN (Perry)       	      27) Alaska (west)
13) Central - IN (Starke)      	      28) Aleutian Islands
14) Central - MI (Wisconsin border)   29) Hawaii
15) Central - ND (Oliver)
 
#? 5
 
The following information has been given:
 
       	United States
       	Eastern - IN (most areas)
 
Therefore TZ='America/Indiana/Indianapolis' will be used.
Local time is now:     	Thu Sep 15 20:50:04 EDT 2016.
Universal Time is now: 	Fri Sep 16 00:50:04 UTC 2016.
Is the above information OK?
1) Yes
2) No

It looks like I made the wrong choices. Whoops. Good thing it asks me to confirm! 🙂

What if you realize that the clock is wrong?

Changing the Time
Use the format “2016-09-15 20:54:00” and pass it to the timedatectl utility.

timedatectl set-time "2016-09-15 20:54:00"

You can also pass the time without the date.

Note: If you try this with NTP enabled you’ll receive an error. So let’s take care of that, too.

Failed to set time: Automatic time synchronization is enabled

Disable Time Synchronization

timedatectl set-ntp false
 
NTP enabled: no
NTP synchronized: yes

Note that after making these adjustments your time will all be local and there won’t be any synchronization occurring.

NTP enabled: no
NTP synchronized: no

We’ll talk about managing time servers in another post.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.