[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

apt-get cron job

Hi all,

 I've got a useful cron job that many of you may find useful.  It uses
apt-get to download updated packages in the wee hours of the morning while
the rest of the internet sleeps (well, at least most of it sleep :).  I
mentioned it on my local LUG list, and Ben Armstrong gave me some helpful
advice.  First, it is too small to package by itself, and second, he
recommended asking some of my questions on debian-devel, so here I am :)

 I use this line in /etc/crontab on my woody system:
42 6    * * sun root    /usr/bin/apt-get update ; /usr/bin/apt-get -q -d -y -u dist-upgrade ; /usr/bin/apt-get autoclean

 It runs at 6:42 every Sunday morning.  Since I don't redirect the
output anywhere, it gets mailed to root, as a reminder that 
apt-get dist-upgrade can be run without fetching anything from the network. :)
It does not, however, actually carry out the upgrades.  This is a Good
Thing, because you can easily not upgrade if you are too busy to risk a
broken system, or if it is a really bad time for the system to possibly
become unstable.  This is because upgrading is an opt-in thing every
week: you don't have to turn anything off to not change your system at all,
except for the packages in your /var/cache/apt.

Question: Is it safe to use -y here?  I think it is, because the only
question that gets asked is whether to proceed with the download or not.
However, I'm worried that there might be times when apt asks some other
questions even though I tell it to only download, not unpack, the new
packages.  It would be very inappropriate to answer yes automatically to any
questions other than whether to proceed with the download.

 If this wasn't too small to package by itself, I would have had an
installer that could generate a random time between 3:00 and 7:00 am on
random days of the week for the update to run, so not every Debian system 
using this is upgrading at the same time.  Maybe apt should give this as an
option in its installer?

 Another thing: http_proxy is probably not set here, since I set http_proxy
from /etc/profile and this runs from cron.  Is there a standard place to
store proxy config info, or should the package installer ask for one?

 Ben tells me that I should write something to put in
/usr/share/doc/apt/examples and submit this as a wishlist bug against apt.
I'll do this unless someone here tells me they've put i in already :)

 Any suggestions/comments?  I'd be surprised if I'm the first person to
think of this, but I didn't see anything that suggested it anywhere.
 (BTW, I skim debian-devel-digest, but I wouldn't mind getting cc'ed on
anything about this.)

#define X(x,y) x##y
DUPS Secretary ; http://is2.dal.ca/~dups/
Peter Cordes ;  e-mail: X(peter@cordes.phys. , dal.ca)

"The gods confound the man who first found out how to distinguish the hours!
 Confound him, too, who in this place set up a sundial, to cut and hack
 my day so wretchedly into small pieces!" -- Plautus, 200 BCE

Reply to: