0

Setting the server timezone in CentOS 7

Welcome to post 11 of my 100 day challenge. Checkout my introduction for some background.

This post discusses the method of setting the server timezone in CentOS 7. This is important as it ensures that cron jobs are ran at the time you expect them to and items such as log files reflect the actual time.

To list the available timezones, login to your server and run the command below:

<code class=" hljs lasso">sudo timedatectl <span class="hljs-built_in">list</span><span class="hljs-attribute">-timezones</span>  
</code>

The output of the command give you something similar to the excerpt below:

Europe/Istanbul
Europe/Jersey
Europe/Kaliningrad
Europe/Kiev
Europe/Lisbon
Europe/Ljubljana
Europe/London
Europe/Luxembourg

In order to set the timezone for example to Europe/London, you can run the following command:

<code class=" hljs lasso">sudo timedatectl <span class="hljs-built_in">set</span><span class="hljs-attribute">-timezone</span> Europe/London  
</code>

To confirm that the change has taken place you can run the command below:

<code class=" hljs bash"><span class="hljs-built_in">sudo</span> timedatectl  
</code>

You should get an output similar to the excerpt below:

Local time: Mon 2015-01-12 21:26:37 GMT
Universal time: Mon 2015-01-12 21:26:37 UTC
Timezone: Europe/London (GMT, +0000)
NTP enabled: n/a
NTP synchronized: no
RTC in local TZ: no
DST active: no
Last DST change: DST ended at
Sun 2014-10-26 01:59:59 BST
Sun 2014-10-26 01:00:00 GMT
Next DST change: DST begins (the clock jumps one hour forward) at
Sun 2015-03-29 00:59:59 GMT
Sun 2015-03-29 02:00:00 BST

Subscribe to my feed either by E-mail or by RSS to receive updates as they happen.

Can you improve on any of the tips I’ve discussed here? If you can let me know in the comments.

Jason Edwards