我管理着大约 7 台 Debian 服务器,我想将它们设置为自动更新。所以,我创建了一个脚本:
#!/bin/sh
apt-get update
apt-get upgrade
Run Code Online (Sandbox Code Playgroud)
并将其放在root's crontab 列表中。不幸的是,它总是挂在升级部分,询问我是否确定要升级。因为它是一个 cron 工作,所以我看不到输出,直到它通过电子邮件告诉我它失败了。有没有办法让它跳过那个提示,然后自动升级?
Art*_*ldt 56
使用 -y 选项 apt-get 让它不询问。来自man apt-get:
-y, --yes, --assume-yes
Automatic yes to prompts; assume "yes" as answer to all prompts and
run non-interactively. If an undesirable situation, such as
changing a held package, trying to install a unauthenticated
package or removing an essential package occurs then apt-get will
abort. Configuration Item: APT::Get::Assume-Yes.
Run Code Online (Sandbox Code Playgroud)
您还可以设置 DEBIAN_FRONTEND 环境变量
DEBIAN_FRONTEND=noninteractive apt-get -y upgrade
Run Code Online (Sandbox Code Playgroud)
Bra*_*iam 33
好吧,也许您使用了错误的工具。unattended-upgradespackage 每日安装安全升级(可配置),可以配置哪些包升级或不升级等。 可以使用:
sudo apt-get install unattended-upgrades
Run Code Online (Sandbox Code Playgroud)
来自man unattended-upgrades:
配置是通过 apt 配置机制完成的。默认配置文件可以在 /etc/apt/apt.conf.d/50unattended-upgrades 找到
jit*_*ter 16
虽然之前的答案提供了信息,但它们并没有规避在upgrade. 因此,我正在使用以下内容:
export DEBIAN_FRONTEND=noninteractive
export DEBIAN_PRIORITY=critical
sudo -E apt-get -qy update
sudo -E apt-get -qy -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" upgrade
sudo -E apt-get -qy autoclean
Run Code Online (Sandbox Code Playgroud)
要包括像内核这样的“分发”升级,请使用该dist-upgrade命令。
有关这些参数的详细信息,请参阅手册dpkg。
重要说明:需要调用sudo包括-E参数:
Indicates to the security policy that the user wishes to preserve their existing environment variables. The security policy may return an error if the user does not have permission to preserve the environment.
否则,这些EXPORT语句不会影响apt-get!
归功于Remy van Elst!谢谢!
| 归档时间: |
|
| 查看次数: |
60362 次 |
| 最近记录: |