Index

Apt Update Script

I wrote this little script so that I wouldn't have to remember to run apt-get update every day. It only outputs anything if there actually is something to install so it won't bombard my inbox every day.

The Code

#!/bin/bash
#
# Cron Script - run from /etc/crontab or /etc/cron.daily
#
# Runs "apt-get update" and prints the output of a simulated
# dist-upgrade if new packages are found.

if [[ `apt-get update 2>&1 | grep Get` ]]; then
  if [[ `apt-get --simulate dist-upgrade 2>&1 | grep Inst` ]]; then
    apt-get --simulate dist-upgrade
  fi
fi

Download

cron_apt-update


2005-05-26 Copyright Mattias Wikström (email: me at domain)