How To Change Timezone on a Linux server

If you are renting a, or hosting your own, Linux server with a major service provider, chance are that it is hosted on a data center on a different time zone than you work/live.
For the most part it isn’t an impairment on using the service, but one of the few inconveniences is the extra attention that you must pay when you are doing some activity that involve dates, like setting a cron job or analyzing the logs and matching them to the activities you made. This inconvenience is caused by the fact that usually the server time is set on the local time of the data center where it resides and not your place of work or house.
One solution of this inconvenience is to change the timezone setting on the Linux server to match your.

Generally, on a Linux server the timezone configuration is handled by:

  • /usr/share/zoneinfo/ – a system directory that contains various default files for all the timezone. For example, the file /usr/share/zoneinfo/Europe/Rome contain the configuration for Italy.
  • /etc/localtime – it is a symlink to one of the file in the above directory and its job is to indicate what is the timezone used by the Linux server’s date.

How To Change Timezone on a Linux server
To check what timezone your server is currently using, use these commands:
date
ls -l /etc/localtime

To change timezone on a Linux server, first find the path of your desired timezone configuration file inside /usr/share/zoneinfo/, then on a terminal (be sure to be connected as root) give the following commands:
mv /etc/localtime /root/timezone.old
ln -s /usr/share/zoneinfo/[your desired timezone] /etc/localtime

Verify new settings by typing again the following two commands:
date
ls -l /etc/localtime

The server will now use the timezone you want, but there is another important step you must follow: if you previously have set cron jobs, script, or other setting with the previous timezone in mind you must reconfigure them to be sure that they run on the right time.