When you are a webmaster managing online servers, there some things you usually do when setting up a new server. Things like setting the root password, configuring the hostname of the server and many others.
One area that’s very important is configuring the internal clock on the server, but few webmasters forget to do this. Setting the correct timezone on the server isn’t required but it’s important.
If you don’t configure the internal clock or add the correct timezone to the server, the server won’t stop working. In fact, all the services and application will continue to work just fine if you forget to setup the correct timezone.
The area you may run into trouble if you don’t set the correct timezone is server reporting. Your server reports may not generate in the time you want them, because the server clock is setup for a different timezone and services like caching may not be caching properly.
This brief tutorial is going to show you how to configure the correct timezone in CentOS 7 if you haven’t already done so.
With CentOS 6 and 6.5 it was simple as copying the correct timezone to the localtime in the /etc/ directory from /usr/share/zoneinfo directory. It may still be possible to do that in CentOS 7.
CentOS 7 introduces a new command to set the correct timezone. With this one command, you can configure the timezone of your choice and have your system updated.
- Setting up the correct timezone in CentOS 7
To configure the correct time zone in CentOS 7 , run the commands below to first list all the available timezone for your system. The list is ordered alphabetically based on content, country and city.
To list the available timezones, run the commands below.
sudo timedatectl list-timezones
This will list the timezones as followed
Africa/Abidjan
Africa/Accra
Africa/Bamako
...
...
America/Menominee
America/Panama
America/Regina
....
....
Europe/Berlin
Europe/Athens
When you go through the list and you’re identify the correct timezone for your servers, run the commands below to set up.
For example, if your server is in the Central timezone in the United States, you’ll want to choose America/Chicago.
The the timezone for Central in US, run the commands below.
sudo timedatectl set-timezone America/Chicago
To view the status of the change, run the commands below.
sudo timedatectl
That’s it.
To automatically synchronize your server internal clocks using ntp servers online, run the commands below to install NTP client.
sudo yum install ntpdate
After installing it, run the commands below to synchronize the clock to one of the many NTP servers online. Here’s one server listed for the US areas.
sudo ntpdate 0.us.pool.ntp.org
Finally, run the commands below to change the hardware clock.
sudo hwclock --systohc
Enjoy!
Frequently Asked Questions
How do I configure server timezone in CentOS 7?
To configure server timezone in CentOS 7, you can use the command 'timedatectl set-timezone <desired_timezone>'. This command allows you to set the correct timezone easily.
What happens if I don't set the correct timezone on my CentOS 7 server?
If you don't set the correct timezone on your CentOS 7 server, it may not affect the functionality of the server itself, but it can lead to issues with server reporting and caching.
How can I list all available timezones in CentOS 7?
To list all available timezones in CentOS 7, you can use the command 'timedatectl list-timezones'. This command will display a list of timezones that you can choose from.
Can I copy the timezone to the localtime in CentOS 7 like in CentOS 6?
In CentOS 7, the process of configuring timezone has been simplified. Instead of copying timezone to the localtime file, you can directly set the timezone using the 'timedatectl set-timezone' command.
What is the importance of configuring server timezone in CentOS 7?
Configuring the server timezone in CentOS 7 is important for accurate server reporting and proper functioning of caching services. It ensures that server activities are timestamped correctly.
How does setting the correct timezone in CentOS 7 impact server performance?
Setting the correct timezone in CentOS 7 does not directly impact server performance but it plays a crucial role in ensuring accurate timestamping of server activities for reporting and caching purposes.
Is it necessary to configure server timezone in CentOS 7?
While not mandatory, configuring the server timezone in CentOS 7 is recommended to avoid issues with server reporting and ensure that server activities are timestamped accurately.
What is the new command introduced in CentOS 7 for setting timezone?
CentOS 7 introduces the 'timedatectl' command for setting timezone. This command simplifies the process of configuring the correct timezone on your CentOS 7 server.