On Linux servers, just like many other things, setting the correct timezone is also very important to make sure things happen as expected. In my case this time around, I had set up an automated data backup script on one of my Amazon Lightsail servers and then set up a cronjob on the Lightsail server to run at a certain time every day to create the automatic data backup, without me having to do anything.
I, however, forgot to set the correct timezone on my Linux server because of this, the backup was generated at the wrong time. Thankfully, I noticed the issue soon enough and made sure to update my Linux server’s timezone.
How To Check The Current Timezone of Linux Server
To check the current timezone of your Linux server, use the command below:
timedatectl status
This is how the response would look
How To Set Timezone on a Linux Server
To set the timezone of my Lightsail server to India, I had to use the following command:
sudo timedatectl set-timezone Asia/India
If you don’t exactly know the timezone name of your region, you can find out the same using the following command:
timedatectl list-timezones
To verify that the timezone has been updated correctly, run the timedatectl status again.
You should see the change in the date now.
Pretty straightforward!