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.

Update 2016-01-09: Updated the script to make it more efficient and compatible with the current /bin/sh (dash).

The Code

#!/bin/sh
#
# Cron Script - place in /etc/cron.daily
#
# Runs "apt-get update" and prints the output of a simulated
# dist-upgrade if any packages would be installed.

apt-get update | grep -q '^Get' \
        && sim=$(apt-get --simulate dist-upgrade) \
        && echo "$sim" | grep -q '^Inst' \
        && echo "$sim"

exit 0

Download

cron_apt-update


2016-01-09 Copyright Mattias Wikström (email: me at domain)