Keep Droplets updated Ubuntu 16.04

August 3, 2016 381 views
DigitalOcean Apache FAQ LAMP Stack Ubuntu 16.04

Im working on setting up a lot of droplets, on Ubuntu 16.04, However it is very time consuming to go into each of the droplets and run sudo apt-get update and sudo apt-get dist-upgrade.

So what I have done is I have added following into my root crontab:
sudo crontab -u root -e

0 3 * * * root /usr/bin/apt-get update && /usr/bin/apt-get dist-upgrade -q -y >> /var/log/apt/myupdates.log

However it is not working, and I was wondering if there is other things I need to think about?

PS: I have followed DO tutorials on how to disable root, so I dont have a root user, is this a problem?


2 Answers

Your idea is good, and removing root would fix it, but I suggest looking into this as it provides more options and integrates better:

  • Thanks, I did try this yesterday. But it just wouldnt work, therefore I went back to Cron.
    I will try to remove root and see.

    This is what I did, removed // on the updates line.

    // Automatically upgrade packages from these (origin:archive) pairs
    Unattended-Upgrade::Allowed-Origins {
    // "${distroid}:${distrocodename}-proposed";
    // "${distroid}:${distrocodename}-backports";


    // Automatically reboot WITHOUT CONFIRMATION
    // if the file /var/run/reboot-required is found after the upgrade
    Unattended-Upgrade::Automatic-Reboot "true";

    // If automatic reboot is enabled and needed, reboot at the specific
    // time instead of immediately
    // Default: "now"
    Unattended-Upgrade::Automatic-Reboot-Time "02:00";

    and in the other file I have exactly this:
    APT::Periodic::Update-Package-Lists "1";
    APT::Periodic::Download-Upgradeable-Packages "1";
    APT::Periodic::AutocleanInterval "7";
    APT::Periodic::Unattended-Upgrade "1";

    Any idea why it doesnt work?

    • Well it uses /etc/cron.daily/apt, have you given it 24 hours to see if it doesn't work?
      Also maybe no updates were issued in that time.
      It should work

  1. You do have a root user, the password is disabled(! in /etc/shadow), but you can still use sudo -i, su is blocked.
  2. Remove root from the entry, it should be: 0 3 * * * /usr/bin/apt-get update && /usr/bin/apt-get dist-upgrade -q -y >> /var/log/apt/myupdates.log (I had the same issue a few months ago)
Have another answer? Share your knowledge.