Tuesday, September 9, 2008

Replacing update-notifier with a cron script in Xubuntu

Update-notifier does a lot of good things. It shows you when a package manager is working in the background, it automates security updates, it caused updates to be downloaded in the background, and it provides a convenient icon to click on and launch update-manager. Good stuff.

But it's daemon eats an annoying trickle of ram and resources.

I have it set to update weekly, so the rest of the time it's just eye candy. Much of it's power is wasted on my scheduled update cycle. Time to find a replacement with less overhead.

The simple solution: Really, all I need is to run update-manager weekly. So add the following to your user crontab (crontab -e):

#Reminder bot - this e-mail replaces the update-notifier package
# nail must be instaled, it is part of the heirloom-mailx package
40 7 * * sun /usr/bin/nail -s "Reminder Bot: Run Update-Manager" me@example.com >/dev/null
or instead of using nail (to e-mail the notice), I can simply use zenity to create a pop-up:
#Reminder bot - this e-mail replaces the update-notifier package
40 7 * * sun DISPLAY=:0.0 /usr/bin/zenity --info --title "Reminder!" --text "It's time to run Update-Manager"
or zenity can also create a notification-area icon:
#Reminder bot - this e-mail replaces the update-notifier package
40 7 * * sun DISPLAY=:0.0 /usr/bin/zenity --notification --text "Reminder: It's time to run Update-Manager"

and I'll get a reminder e-mail every Sunday morning at 7:40 am...if I'm awake. Then I launch update-manager from the menu or command line...if I want.


The lazy solution: The simple solution has a drawback - none of the packages are downloaded yet, so the update might take a while (zzzzz). An additional cron entry, though, will have everything downloaded and ready.

Edit the root crontab: sudo mousepad /etc/crontab

Add the line 42 6 * * sun root apt-get update && apt-get autoclean && \apt-get -q -d -y -u upgrade (source)

This will download the updated and upgraded packages on Sunday mornings about an hour before the reminder e-mail, plenty of time.


In theory we could try 42 6 * * sun root apt-get update && apt-get autoclean && \apt-get -q -d -y -u upgrade && /usr/bin/nail -s "Reminder Bot: Run Update-Manager" me@example.com and have it all in one place, but I'll find that confusing in another 6 months.


Removing update-notifier and update-notifier-common: Nothing depends on the package in Xubuntu 8.04, so a simple sudo apt-get remove update-notifier update-notifier-common gets rid of the packages, freeing up a whopping 426kb of disk space.


I find I don't miss the old notifier at all.

No comments: