Raspberry Pi: Weekly Updates

By | November 9, 2018

By using a simple bash script in Raspbian it is possible to update your Raspberry Pi software automatically. Move to the directory where you store your scripts then use nano to start making a new file.

$ cd ~/Code
$ nano update.sh

Copy/paste the following code into the file then save it.

#!/bin/bash
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get autoremove
sudo apt-get autoclean
sudo reboot

Now make the file executable by issuing the following command.

$ sudo chmod +x update.sh

Make the file run on a weekly schedule by making an entry in crontab by running the following command.

$ crontab -e

Enter the following line at the bottom in crontab to run the update script every Saturday at midnight.

0 0 * * SAT bash /home/pi/Code/update.sh

That’s all there is to it.

Leave a Reply

Your email address will not be published. Required fields are marked *