https://wiki.tamerz.com/index.php?title=Debian/Ubuntu&feed=atom&action=historyDebian/Ubuntu - Revision history2024-03-28T20:07:09ZRevision history for this page on the wikiMediaWiki 1.31.7https://wiki.tamerz.com/index.php?title=Debian/Ubuntu&diff=6&oldid=prevTmctigue: 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."..."2021-12-01T10:39:09Z<p>Created page with "Script to update everything: <strong>/usr/local/sbin/update-all:</strong> #!/bin/bash if <a href="/index.php?title=$EUID_-ne_0&action=edit&redlink=1" class="new" title="$EUID -ne 0 (page does not exist)"> $EUID -ne 0 </a>; then echo "This script must be run as root."..."</p>
<p><b>New page</b></p><div>Script to update everything:<br />
<br />
<strong>/usr/local/sbin/update-all:</strong><br />
#!/bin/bash<br />
<br />
if &#91;&#91; $EUID -ne 0 &#93;&#93;; then<br />
echo "This script must be run as root." 1>&2<br />
exit 1<br />
fi<br />
<br />
/usr/bin/apt-get update && \<br />
/usr/bin/apt-get dist-upgrade -y && \<br />
/usr/bin/apt-get autoremove -y<br />
<br />
if &#91; -f /var/run/reboot-required &#93;; then<br />
echo "One or more updates require a reboot of the machine." 1>&2<br />
fi<br />
<br />
To run it in cron as root:<br />
SHELL=/bin/bash<br />
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin<br />
<br />
# m h dom mon dow command<br />
0 3 * * * /usr/local/sbin/update-all > /var/log/update-all.log 2>&1</div>Tmctigue