15

I have installed Apt-Cacher NG to provide a cache of packages for several machines. I therefore see no point in having aptitude/apt-get keeping their own (second) cache in /var/cache/apt/archives. I realise I can empty this cache with sudo apt-get clean, but is there some way of configuring apt-get to automatically clean the cache when an install has completed?

Blair
  • 2,891
  • 2
  • 20
  • 16

3 Answers3

10

According to the documentation you can add a config file to /etc/apt/apt.conf.d/ named no-cache containing Dir::Cache ""; and Dir::Cache::archives ""; according to manual of apt.conf. There is a bug report raising issues with this method, and I don't recommend it.

There is one remaining method according to this tutorial:

echo 'DPkg::Post-Invoke {"/bin/rm -f /var/cache/apt/archives/*.deb || true";};' | sudo tee /etc/apt/apt.conf.d/clean

This will carry out an rm command just before apt quits.

Zanna
  • 72,312
sagarchalise
  • 24,306
0
echo 'APT::Keep-Downloaded-Packages "false";' \
      > /etc/apt/apt.conf.d/01disable-cache

For more details, see: https://superuser.com/questions/1405001/why-does-apt-do-not-store-downloaded-packages-anymore

-2

I think that what you are looking for is:

/etc/apt/apt.conf.d$ cat 04autoclean
APT::Clean-Installed "true";
/etc/apt/apt.conf.d$ 
Eliah Kagan
  • 119,640
Victor
  • 1