Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm using puppet to admin a cluster of debian servers. I need to change the timezone of each machine on the cluster. The proper debian way to do this is to use dpkg-reconfigure tzdata. But I can only seem to change it if I use the dialog. Is there some way to automate this from the shell so I can just write an Exec to make this easy?

If not, I think the next best way would probably be to have puppet distribute /etc/timezone and /etc/localtime with the correct data across the cluster.

Any input appreciated!

share|improve this question

4 Answers 4

up vote 58 down vote accepted

You need to specify the frontend as `noninteractive' and it will save your current settings.

dpkg-reconfigure will take the current system settings as gospel, so simply change your timezone the way you would normally and run it with the non-interactive flag

e.g. for me to change to "Europe/Dublin" where I am:

# echo "Europe/Dublin" > /etc/timezone    
# dpkg-reconfigure -f noninteractive tzdata

Obviously this allows you to use puppet/cfengine as you like to distribute /etc/timezone also.

share|improve this answer
I'm getting access denied from sudo echo "XXX" > /etc/timezone. But when running with vim (sudo vim /etc/timezone) it works fine. Any ideas? –  SilentSteel Jan 16 at 15:12
Solved: If you get access denied, you may need to first sudo chmod 666 /etc/timezone and then sudo chmod 644 /etc/timezone after you make the change. –  SilentSteel Jan 16 at 15:27
as an alternative to changing permissions, you could do something like this. echo 'Europe/Dublin' | sudo tee /etc/timezone > /dev/null –  gorelative Jan 19 at 14:04

You should be able to use debconf-set-selections to preset the configuration. Install debconf-utils and run debconf-get-selections | grep tzdata on a properly configured system to figure out what to set it too.

share|improve this answer
For things that are debconf based, this should work. But tzdata prefers the config from /etc/timezone. So this does not work on an already installed (wheezy) system. –  Elrond Jul 18 '14 at 15:01

You can also use the recipe from the Puppet wiki:


This simply replaces /etc/localtime with the appropriate zoneinfo file from /usr/share/zoneinfo.

I'm not sure if dpkg-reconfigure does anything extra, but I have used the above recipe and it works perfectly.

share|improve this answer

Its very simple and only need to type a command and answer the simple questions.
then run:

share|improve this answer
man tzselect: "Note that tzselect will not actually change the timezone for you. Use 'dpkg-reconfigure tzdata' to achieve this." –  S.Pinkus Dec 21 '14 at 9:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.