I wrote a simple script that is basically apt-get update, upgrade, autoremove and autoclean, like this:
apt-get check && apt-get update && apt-get upgrade && apt-get autoremove && apt-get autoclean
I put this into my crontab, opening the tab with sudo
0 24 * * * /home/ubuntu/script.sh
Would this make the script run every 24 hours? Or would it not work? I'm asking for educational purposes, I'm not looking for more efficient ways just yet.
apt-get update
without the '-y' flag asks for user input. The next morning, when you kill the stuck headless process, also remember to release the apt lockfile since apt could not. (the lockfile simply makes sure that a maximum of one instance of apt can be running at a time).