How to: Set the Timezone on Ubuntu Server
How to: Set the Timezone on Ubuntu Server
If you are using a VM hosted with a public cloud provider you probably have realized that they generally are deployed using UTC as the default timezone. In Windows I was very familiar modifying that but now that I have deployed an Ubuntu server I wasn’t sure where to begin. Every time I executed a php script on the terminal I got a warning that I should not rely on the server timezone (UTC) but set the right one on my php.ini file. I ended up doing that but I realized all the logs, etc are still based on the UTC timezone so I decided it was time to set my timezone on my Ubuntu server.
It turns out it is rather simple, just a few commands and considerations and you are set and done!
I. Verify the current settings and time using date (there is also a timezone file in /etc/timezone):
date
Wed Dec 10 04:10:03 UTC 2013
or as mentioned you should also check what is your current time zone (in my case, I was originally in UTC)
more /etc/timezone
Etc/UTC
II. To change the timezone you need to execute sudo dpkg-reconfigure tzdata.
This will launch an interface for you to select the timezone from a number of options. If you have installed Ubuntu Server before it is the same screen as when you install your server. When you are done you´ll receive the following output on the terminal:
sudo dpkg-reconfigure tzdata
Current default time zone: ‘America/Mexico_City’
Local time is now: Tue Dec 09 22:12:45 CST 2013.
Universal Time is now: Wed Dec 10 04:12:45 UTC 2013.
as you can see this is rather simple.
III. Don’t forget to restart cron
Otherwise it won’t pick up the timezone change. If possible I recommend a whole server restart just to make sure everything picks up the change:
sudo service cron restart
Love
Can we use Let's Encrypt, the free and open certificate authority?
Hola! gracias por la info, me sirvió el comando sacandole el nombre del server. En mi caso, fue una migración…
Yes 3rd option helped me too. I removed the WC key Values from config file then started working.
I know this is from 2014. But really, thank you!