Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've been curious if there is a way to make it so that the Update Manager can check for updates say every few hours rather than daily. Now, I know that I can run sudo apt-get update to check, but it would be nice to have it show it to me more often...I love having the most up to date system that I can.

share|improve this question

3 Answers 3

up vote 4 down vote accepted

I use two scripts, one that runs in the background whenever I am logged in, and one that is allowed through sudo without a password to apt-get update and additionally download packages.

You can download the two scripts I wrote here, or copy and paste them into gedit from below: http://ubuntuone.com/0tNctmQnF2peAsUmaqtyo3

These are the two scripts I wrote:
The first should be called 'background-runner':

#! /bin/bash

# This will connect and download any new packages every two hours.
# Ideal for use on the development release to save time.
# Downloads almost all packages, not just security releases.
sleep 10m

while true; do
    sudo /usr/local/bin/package-downloader update
    sleep 120m
done

And the second should be called 'package-downloader':

#! /bin/bash
# This runs as root and is allowed through sudo to only download packages.

if [ $1 = 'update' ]; then
    apt-get update
fi

if [ $1 = 'download' ]; then
    apt-get update
    apt-get --yes --download-only upgrade
fi

To set this up, download or copy and paste the files into gedit and save the files with the names noted above. cd to their location in the terminal and run the following commands:

sudo cp package-downloader background-runner /usr/local/bin
sudo chmod +x /usr/local/bin/package-downloader /usr/local/bin/background-runner

Now we have to allow the package-downloader script through sudo. Open a terminal and type

sudo visudo

at the bottom of the file add the following line replacing MYUSER with the username you run as, and then hit ctrl+x and then enter to save.

 MYUSER ALL=(root) NOPASSWD: /usr/local/bin/package-downloader

Now navigate to 'Startup Applications.' Click add. Name it whatever you like, and enter /usr/local/bin/background-runner for the command. Save this and exit out. enter image description here

Having logged out and logged back in, the scripts will perform an apt-get update every two hours. You might want to disable the automatic check for updates through the Update Manager's Software Sources dialogue, which you can reach by clicking settings in the bottom left corner. This way update-manager will not check for updates when the script is already doing so more frequently. enter image description here

The scripts linked here will just do apt-get update by default. If you would like them to also download any packages, you simply need to edit the line in background-runner that says:

 sudo /usr/local/bin/package-downloader update

and have it say

 sudo /usr/local/bin/package-downloader download

The same can be done for changing the amount of time in between updates and downloads, just change 120m in

 sleep 120m

to your desired amount of time in minutes (m) hours (h) seconds (s).

FYI: This could potentially be a security risk if the permissions to /usr/local/bin have been changed. Because package-downloader is a script, and allowed through sudo, BE SURE ONLY ROOT CAN WRITE TO IT!

share|improve this answer
    
Simply brilliant! Thank you!!! –  Ryan McClure Apr 26 '12 at 9:43
    
You're very welcome. :) –  Mark Paskal Apr 26 '12 at 9:47

Post your curiosity here http://brainstorm.ubuntu.com/ and see developers could add one more option as "every hour" or "every minute" by default in the update manager.

share|improve this answer
    
Would you say that currently there is no way? I'll go ahead and post that now –  Ryan McClure Apr 26 '12 at 7:52
    
Hm..., how about every second? Can you provide justifications for checking for updates so often. –  mikewhatever Apr 26 '12 at 8:00
    
@mikewhatever Every second would be a bit much :P But one day, for me, is simply too long. I can do it manually, but sometimes I don't think about it. It's a convenience thing. –  Ryan McClure Apr 26 '12 at 9:44

Create a cronjob each period of time which runs

'sudo apt-get update && sudo apt-get upgrade'

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.