I want to set up an Ubuntu laptop for a person with 0 experience of linux and who does not want to learn more than just use a few programs (replacement for Windows for an older family member; she really likes ubuntu, finds it easy enough to use, and snappy :) ).
I want to make sure all updates are applied. I am aware of (and have enabled / set up for full update once a day) unattended-upgrades
. However, I am worried that if the laptop is mostly being used for quite short amounts of time and conscientiously shut off, the upgrades may not be applied by the unattended thing.
Is this worry based on reality? Does
unattended-upgrades
attempt to upgrade immediately when the laptop is turned on (does not seem so as I still get quite a lot installed withapt
each time I switch it on, thoughunattended-upgrades
is set up), or does it do it only 'once a day at 01.00 am' or something like that, in which case it may never be called?Would calling this kind of script from the root crontab (ie adding an
@reboot bash script_update.sh
tosudo crontab -e
) help? :
#!/bin/bash
# A little script to:
# - wait that internet is available
# - wait for the automatic software update to be finished running
# - apply the apt-get update and upgrade to the system
# This means that updates are installed automatically without
# asking confirmation. This should be ok for most vanilla uses.
#
# SETUP
#
# set the XX_SET_PATH to the log file
#
# To make it run automatically, put it in crontab:
# sudo crontab -e
# and in the root crontab that gets opened:
# @reboot bash PATH_TO_THE_SCRIPT.sh
function check_online
{
netcat -z -w 5 8.8.8.8 53 && return 1 || return 0
}
function wait_online
{
echo "wait to be online"
declare -i IS_ONLINE=0
while [ $IS_ONLINE -eq 0 ]; do
# We're offline. Sleep for a bit, then check again
sleep 2;
check_online
IS_ONLINE=$?
done
echo "now online"
}
{
echo " "
echo "new reboot"
date
whoami
wait_online
echo "wait for 20 minutes to make sure no conflicting catch of dpkg lock"
sleep 1200
echo "now start update upgrade..."
apt-get update
apt-get upgrade -y
apt-get autoremove
} >> XX_SET_PATH 2>&1