我想设置一个脚本来自动更改机器上的时区(运行 ubuntu 11.10)并为debconf数据库设置正确的值。我尝试了以下方法,但它不起作用(最后,当前时区保持不变,如果我手动运行该dpkg-reconfigure tzdata命令,所选值确实是旧值):
#!/bin/sh -e
echo "tzdata tzdata/Areas select Europe" | debconf-set-selections
echo "tzdata tzdata/Zones/Europe select Madrid" | debconf-set-selections
echo "tzdata tzdata/Zones/America select " | debconf-set-selections
dpkg-reconfigure -f noninteractive tzdata
Run Code Online (Sandbox Code Playgroud)
所以,现在,我做它与文件搞乱/etc/localtime和/etc/timezone直接,但我宁愿喜欢dpkg-reconfigure和debconf方式。