Setting the timezone for your server is a critical first step in basic system administration. If your server doesn’t tell good time, it can cause you plenty of headaches. Need to know when an email came in? Need a cron job to run at a specific time? Need an SSL to renew at a regular interval? Databases, logging, scheduling, and automation all require accurate timekeeping. You get the picture: time is money. So in this article, we’ll tell you how to set your Ubuntu server to the proper timezone.
- Get Available Timezones
- Set The Server Timezone To Your Desired Location
- Verify You Have Set The Correct Timezone
Note: the commands in this article require root access or the usage of a sudo user. If you don’t know what that means be sure to check out our full guide on creating sudo users in Ubuntu.
Get Available Timezones
First of all, before you set the time of your server, you need to know what times are available. For example, I can’t set my Ubuntu clock for Miami, Fl. But I can set it for New York, NY.—which will be the same time, for all intents and purposes.
You can see a list of all available timezones by running this command:
timedatectl list-timezones
That will yield 610 results, so it’s not very helpful. With the grep command, you can limit your output to a search query. For example, if you wanted to find “New York”, you could search for it like this:
timedatectl list-timezones | grep "New"
And you will get the following output:
America/New_York America/North_Dakota/New_Salem Canada/Newfoundland
Set The Server Timezone To Your Desired Location
Now that you have a list of available timezones, find one that’s closest to you and set it for your system. You can do that with the following command:
sudo timedatectl set-timezone <desired timezone>
For example, if you want to set your timezone for America/New_York
(as in the above example), the command would look like this:
sudo timedatectl set-timezone America/New_York
Verify You Have Set The Correct Timezone
Now you have run a command to set the timezone for your server, but how do you know you did it right? You can always double-check you have the correct timezone set with the following command:
timedatectl
This command will output the current time, date, and other timezone information on your Ubuntu server.
You will get an output similar to this one:
Well done! Now your Ubuntu cloud server can tell time properly. For more system admin tutorials and information, check out our full cloud server guide.