Friday, April 30, 2010

Simple apt daily update script

Here is a simple apt update script (file /usr/local/sbin/apt-update):
#!/bin/sh

# Download only; package files are only retrieved, not unpacked or
# installed.
apt-get -dqq update
apt-get -dyqq upgrade
Make this file executable:
chmod +x /usr/local/sbin/apt-update
Run it by cron per schedule (file /usr/local/etc/cron.d/apt-update):
#
# Regular cron jobs for apt-update
#
SHELL=/bin/sh
PATH=/usr/local/sbin:/bin:/usr/bin
LOG=/dev/null

# Run on Sun, Tue, Thu at 2:05 AM
# m h dom mon dow user  command
05 2 * * 0,2,4 root test -x /usr/local/sbin/apt-update && apt-update > $LOG
Let cron know about our scheduled apt-update:
ln -s /usr/local/etc/cron.d/apt-update /etc/cron.d/cron-apt-update

No comments :

Post a Comment