Debian脚本在apt-get安装期间删除日志记录


0

我试图在apt-get安装之后删除debian发出的日志

Ign http://ftp.uk.debian.org jessie InRelease
Hit http://ftp.uk.debian.org jessie-updates InRelease
Get:1 http://security.debian.org jessie/updates InRelease [63.1 kB]
Hit http://ftp.uk.debian.org jessie Release.gpg
Hit http://ftp.uk.debian.org jessie-updates/main Sources
Get:2 http://ftp.uk.debian.org jessie-updates/main amd64 Packages/DiffIndex [3,472 B]
Get:3 http://ftp.uk.debian.org jessie-updates/main Translation-en/DiffIndex [1,720 B]
Hit http://ftp.uk.debian.org jessie Release
Get:4 http://security.debian.org jessie/updates/main Sources [131 kB]
Hit http://ftp.uk.debian.org jessie/main Sources
Hit http://ftp.uk.debian.org jessie/main amd64 Packages
Hit http://ftp.uk.debian.org jessie/main Translation-en
Get:5 http://security.debian.org jessie/updates/main amd64 Packages [237 kB]
Get:6 http://security.debian.org jessie/updates/main Translation-en [129 kB]
Fetched 565 kB in 3s (158 kB/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... The following package was automatically installed and is no longer required:
  libio-socket-ip-perl
Use 'apt-get autoremove' to remove it.
Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

我想删除它。无论如何,在编写脚本时是否要阻止它?


显示您正在执行的命令 - 特别是,您使用的是 -q 国旗到 apt-get
Toby Speight

-q做什么?
Dectom

正如它在手册页中所说的那样 - “安静;产生适合记录的输出,省略进度指示器。更多的q将产生更多的安静,最多可达2个。” 。你问过之前你确实阅读过这个手册页,我希望?
Toby Speight

Answers:


2

重定向 stdout/dev/null 通过附加 > /dev/null 任何命令:

apt-get update > /dev/null

还要重定向 stderr/dev/null 附加 2>&1

apt-get update > /dev/null 2>&1

在不提示的情况下升级或安装软件包 [Y/n]-y

apt-get upgrade -y > /dev/null 2>&1
apt-get install <package> -y > /dev/null 2>&1

您也可以将其发送到日志文件:

apt-get upgrade -y > script.log 2>&1

单身 > 将覆盖该文件,记录多个命令使用两个 >>,这将导致输出附加到文件的末尾:

apt-get update >> script.log 2>&1
apt-get upgrade -y >> script.log 2>&1

非常感谢。此外,如果我在同一个日志文件中安装多个东西,这会有用吗?
Dectom

我很开心。看到我更新的答案。
rda
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.