Note : Cet article a été publié à l’origine en 2013. Certaines étapes, commandes ou versions de logiciels ont pu changer. Consultez la documentation actuelle de Ubuntu pour les informations les plus récentes.
Prérequis
Avant de commencer, assurez-vous d’avoir :
- A system running Ubuntu (desktop or server edition)
- Terminal access with sudo privileges
- Basic familiarity with Linux command line
How to: Set the (http://en.wikipedia.org/wiki/Time_zone “Time zone”) on (http://www.ubuntu.com “Ubuntu (operating system)”)
If you are using a VM hosted with a public cloud provider you probably have realized that they generally are deployed using (http://en.wikipedia.org/wiki/Coordinated_Universal_Time “Coordinated Universal Time”) as the default timezone. In (http://www.microsoft.com/WINDOWS “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. (http://en.wikipedia.org/wiki/Universal_Time “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
(http://img.zemanta.com/zemified_h.png?x-id=c730fb12-a136-4873-8ae2-b84cdef74890)](http://www.zemanta.com/?px “Enhanced by Zemanta”)