Timezone on AWS Linux AMI
When it comes to datetime everyone prefers to be on current local or the local that he/she can easily adapt to go out for.
So do we need to go through in this article on AWS(Amazon Web Services) Linux AMI. It is the base Linux system that AWS provides and by default, the timezone is set to UTC.
The time on the Amazon Linux AMI is set, by default to UTC.
We are taking an example of a developer/DevOps engineer who used to use IST timezone in his daily life and can easily move around it.
Coming to point now let's do the action of changing timezone
UTC to IST on AWS Linux AMI
Get the Local Time File
Usually, on Linux systems, we can get the local time file at "/etc/localtime". This file will contain the information regarding your system timezone and date time-related information.Get the Right Timezone File
Now we need to get the exact timezone file which can be found under "/usr/share/zoneinfo/".This folder will contain all the time zones available under Linux which can be used to change the datetime of our system easily.
Linux Zone Info |
Make Changes in Effect Now
We need to create a soft link to our local time file which will be linked to our new timezone file.
For this action, we need to run the following command under terminal/ command prompt.
If you are facing any issue regarding permission, please use sudo command to execute the above command like this:
Once this is done, you can check immediate effects which will also reflect on the logs and any date time operation on the server/ machine.
You can see the result here in the below image as
After this, you must handle it in a permanent way because this is the temporary thing. To make this persist for further sessions of the server/machine you need to make changes in the file located at "/etc/sysconfig/clock"
We need to update the ZONE parameter in this file so that it retains.
Once this is done, you can check immediate effects which will also reflect on the logs and any date time operation on the server/ machine.
You can see the result here in the below image as
Linux Time Zone Change Result |
We need to update the ZONE parameter in this file so that it retains.
This parameter specifies the file under "/usr/share/zoneinfo" that is to be used.
In our case, it will be ZONE="Asia/Calcutta"
After this, we are ready to use the system in our own set timezone on the machine for every datetime operation that we perform until unless we explicitly change the datetime or developer express the datetime changes in their code.
Keep Learning and Happy Coding :)
After this, we are ready to use the system in our own set timezone on the machine for every datetime operation that we perform until unless we explicitly change the datetime or developer express the datetime changes in their code.
Keep Learning and Happy Coding :)