10

I have a set of custom commands I run on my computers after I install them. How do I make Ubuntu check for updates every 4 weeks and install them automatically on check?

I would need this done via command line so I can set it up for usual users when I set up their computers.

The first command will make the update manager check for updates every 2 weeks because they not always come so much and to save the bandwidth of the Ubuntu servers.

I also need to set it so that users don't need to click to install updates since it's tiring every time I help a friend set up a computer.

Kangarooo
  • 5,223

4 Answers4

11

First, enable automatic updates like this:

sudo apt-get install unattended-upgrades

You then need to edit its configuration, type

sudo nano /etc/apt/apt.conf.d/50unattended-upgrades

(replace nano with your preferred text editor if you want)

The file looks like this:

Unattended-Upgrade::Allowed-Origins {
        "Ubuntu maverick-security";
//      "Ubuntu maverick-updates";
};

The // means this line is a comment and won't be considered by the program, remove the strokes to include stable release updates in addition to security fixes. Also, replace maverick with the version of Ubuntu you're running.

To set the interval at which the system checks for updates, edit the /etc/apt/apt.conf.d/10periodic file with a text editor:

APT::Periodic::Update-Package-Lists "14";
APT::Periodic::Download-Upgradeable-Packages "14";
APT::Periodic::AutocleanInterval "14";
APT::Periodic::Unattended-Upgrade "14";

In this example, the system is updated every two weeks.

For a more detailed explanation, see Automatic Updates in the Ubuntu server guide.


Note that papukaija's answer is talking about the interval at which the Update Manager dialogue pops up on your screen, I'm guessing that's not what you wan't, but I'm not sure. :)

2

If you mean update everything "updatable", i.e., update ALL your packages, I guess you could cron (within the root cron) than every 28 days apt-get update && apt-get upgrade -y is run.

Some people have problems with crond jobs because of a restrictive PATH setting. Should you have any problem you can define your PATH at the very beginning of the crontab -e file (as suggested in CronHowto)

Also, to check that everything is going OK, I'd log the results, like this:

root@PORTATIL:/var/log$ crontab -l
* * */2 * * /usr/share/myupdate.sh > /var/log/myupdate.log

myupdate.sh could be as simple as this:

#!/bin/bash
#Testing updates
echo "$(date) Crond myupdate sarting."
apt-get update -y
apt-get upgrade -y
echo "$(date)Crond myupdate finished."
luri
  • 4,132
1

You can change the interval between the time when update-manager is run by opening gconf-editor (for example with Alt+F2 and typing gconf-editor). Then locate /apps/update-notifier.

The interval is defined in key regular_auto_launch_interval where the value is number of days. I think that this method doesn't affect the non-graphical automatic updater (unattended-upgrades).

Please note that Ubuntu may not automatically install security updates due to a bug.

papukaija
  • 2,425
0

I put gconftool -s /apps/update-notifier/regular_auto_launch_interval --type int 1 and its opening every day showing i have not installed updates. Does it open if theres no new updates? So then making auto update every 4 weeks would not make this pop up? So then just how to make with CLI to auto install updates every checking every 4 weeks? THats what i want. By not going to Software sources and doing it with mouse. And doing so its possible couse it cant be put more then 2 weeks in there.

Kangarooo
  • 5,223