apt-get install tzdata非交互式 [英] apt-get install tzdata noninteractive

查看:83
本文介绍了apt-get install tzdata非交互式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试

apt-get install -y tzdata

显示用于选择时区的命令行选项.我试图在脚本中使用它来进行一些设置,如何在没有用户输入的情况下使apt-get运行?

the command line option for picking timezone shows up. I am trying to use this in a script to do some setup, how can I make the apt-get run without user input?

我知道可以重新配置tzdata

I know to reconfigure the tzdata I can do

echo "America/New_York" > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata

但是在安装时,即使它没有设置正确的时区,我也需要它完全运行,我可以随时对其进行重新配置.

But when installing I need it to run fully even if it doesn't set the right timezone, I can always reconfigure it.

我尝试了

echo 5 | apt-get install -y tzdata

但是它没有按预期工作.

but it is not working as expected.

推荐答案

这是我使用的脚本

(更新版本,其中包含@elquimista的评论)

#!/bin/bash
export DEBIAN_FRONTEND=noninteractive

ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime
apt-get install -y tzdata
dpkg-reconfigure --frontend noninteractive tzdata

似乎可以正常工作.

作为一个班轮:

DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata

这篇关于apt-get install tzdata非交互式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆