Debian/Ubuntu

From Tamerz
Revision as of 10:39, 1 December 2021 by Tmctigue (talk | contribs) (Created page with "Script to update everything: <strong>/usr/local/sbin/update-all:</strong> #!/bin/bash if $EUID -ne 0 ; then echo "This script must be run as root."...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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