2

I'm trying to remove the log that debian puts out after you apt-get install something

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.

I want to remove this. Is there anyway to stop this whilst scripting?

3
  • 1
    Show the command you are executing - in particular, are you using the -q flag to apt-get? May 10, 2016 at 16:58
  • what does the -q do?
    – Dectom
    May 14, 2016 at 0:46
  • 1
    Exactly as it says in the man page - "Quiet; produces output suitable for logging, omitting progress indicators. More q's will produce more quiet up to a maximum of 2. ". You did read the man page before asking, I hope? May 16, 2016 at 8:05

1 Answer 1

5

Redirect the stdout to /dev/null by appending > /dev/null to any command:

apt-get update > /dev/null

To also redirect stderr to /dev/null append 2>&1:

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

To upgrade or install packages without being prompted for [Y/n] add -y:

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

You could also send it to a log file:

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

A single > will overwrite the file, to log multiple commands use two >>, which will cause the output to be appended to the end of the file:

apt-get update >> script.log 2>&1
apt-get upgrade -y >> script.log 2>&1
2
  • Thanks very much. Also if i'm installing multiple things into the same log file will this work?
    – Dectom
    May 4, 2016 at 23:08
  • Happy I helped. See my uptaded answer.
    – rda
    May 4, 2016 at 23:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .