4

On my Debian 6.0.8 system the /etc/cron.daily/apt file is missing. Therefore, unattended upgrades do not work.

How can I recreate/fix /etc/cron.daily/apt?

robert
  • 143
  • 6
  • It will not help with this problem but to prevent future issues may I suggest etckeeper. All you would have to do is use git to revert the change: https://joeyh.name/code/etckeeper/ – dfc Jan 20 '14 at 03:03

2 Answers2

5

first find which package contains the missing file:

$ dpkg --search /etc/cron.daily/apt
apt: /etc/cron.daily/apt

which is that case is the package "apt", and then re-install it:

$ sudo apt-get -o Dpkg::Options::="--force-confmiss" --reinstall install apt

edit: added the option to force the miss conf

  • 1
    This won't work as the missing file is in /etc and is considered a config file. As such it won't be installed again when doing --reinstall; unless you se -o DPkg::options::=--force-confmiss – alxgomz Jan 19 '14 at 11:32
  • Correct, in that case we need to use the `-o Dpkg::Options::="--force-confmiss"`, so for that example it's `$ sudo apt-get -o Dpkg::Options::="--force-confmiss" --reinstall install apt` – Theofilos Papapanagiotou Jan 19 '14 at 11:37
  • This was very helpful as my virtual hosting provider decided it would be a good idea to remove this file, so even though I thought I had enabled automatic security updates, nothing was actually updated. – Alex Dupuy Sep 29 '14 at 15:10
  • Same thing here with OpenVZ `ubuntu-12.04-x86_64.tar.gz` template. – Jaime Hablutzel Apr 08 '15 at 17:46
1

You should extract the apt deb package in a temp location and then copy the missing file to where it should be. For instance if your apt cache still contains the deb package apt you can do:

cd /tmp
dpkg -x /var/cache/apt/archives/apt_0.9.7.9+deb7u1_amd64.deb .
cp /tmp/etc/cron.daily/apt /etc/cron.daily/

If you don't have the deb file in your cache anymore, just download it and apply the same procedure.

alxgomz
  • 1,630
  • 1
  • 11
  • 14