这篇文章简单memo一下ubuntu或者debian容器下的时区设定。这本来是timedatectl 直接设定就可以解决的问题。
问题1: No such file or directory错误提示
sh-4.3$ timedatectl
Failed to create bus connection: No such file or directory
sh-4.3$
确认之后,发现没有设定/etc/localtime,决定直接设定与设定指向Asia/Shanghai的链接进行解决。
问题2: 权限不足
sh-4.3$ ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
ln: cannot remove '/etc/localtime': Permission denied
sh-4.3$
使用sudo解决问题
sh-4.3$ sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
sh-4.3$ ls /etc/localtime
/etc/localtime
sh-4.3$
问题3: 不存在zoneinfo
sh-4.3$ ls -l /usr/share/zoneinfo/Asia/Shanghai
ls: cannot access '/usr/share/zoneinfo/Asia/Shanghai': No such file or directory
sh-4.3$
因为缺少tzdata,安装tzdata,提示如下问题
问题4: unable to locate package
sh-4.3$ sudo apt-get install tzdata
Reading package lists... Done
Building dependency tree
Reading state information..