Setting the timezone on CentOS 7

Tech
No Comments

To keep ensure your logs are easy to analyse and some scripts operate correctly, it’s a good idea to set your server timezone to match where you are.

Display the current zone (and time) by using the ‘date’ command:

[user@server ~] date
Tue 22 Aug 13:32:27 BST 2017

From the above, you can see my timezone is set to BST.

To view a list of the available timezones, use the following:

[user@server ~] timedatectl list-timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau
Africa/Blantyre ...

You can scroll through these, but it’s a big list.  So we can use the ‘grep’ command to find what we need:

[user@server ~] timedatectl list-timezones | grep Europe
...
Europe/Kirov
Europe/Lisbon
Europe/Ljubljana
Europe/London
Europe/Luxembourg
Europe/Madrid
Europe/Malta
Europe/Mariehamn ...

For my use I need the Europe/London zone so I can set it using:

[user@server ~] sudo timedatectl set-timezone Europe/London

Repeat the ‘date’ command above to make sure it’s all correct and you’re done.

Leave a Reply

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

Fill out this field
Fill out this field
Please enter a valid email address.

Menu