This is a little helper script that runs all the update commands of the Raspberry Pi in an order. Making it more comfortable to use and also possible to tie to a cronjob for automatic system update schedules.
Lets start with creating the script file in our home dir:
$ sudo nano /home/pi/piupdate.sh
Paste the following script into the file:
#!/bin/bash
echo
echo "-> sudo apt-get update"
sudo apt-get update
echo
echo "-> sudo apt-get -y upgrade"
sudo apt-get -y upgrade
echo
echo "-> sudo apt-get -y dist-upgrade"
sudo apt-get -y dist-upgrade
echo
echo "-> sudo apt-get -y autoremove"
sudo apt-get -y autoremove
echo
echo "-> sudo apt-get clean"
sudo apt-get clean
echo
Save and close with CTRL + X and y.
Now make the script exetuable:
$ sudo chmod +x /home/pi/piupdate.sh
Now you can run it by:
$ sudo /home/pi/piupdate.sh
Create a scheduled update service
Go to your crontab to create a cron job:
$ sudo crontab -e
Go to the last line of the file and add at the very bottom:
0 3 * * * /home/pi/piupdate.sh
This will run our update script every day at 3am.
Save and close with CTRL + X and y.
For your own timings and schedules I recommend using crontab.guru.
Thats it with this little helper script!