Debian/Ubuntu
Script to update everything:
/usr/local/sbin/update-all
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root." 1>&2
exit 1
fi
/usr/bin/apt-get update && \
/usr/bin/apt-get dist-upgrade -y && \
/usr/bin/apt-get autoremove -y
if [ -f /var/run/reboot-required ]; then
echo "One or more updates require a reboot of the machine." 1>&2
fi
To run it in cron as root
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow command
0 3 * * * /usr/local/sbin/update-all > /var/log/update-all.log 2>&1