This script automates the update and maintenance process for Raspbian on a Raspberry Pi.
The script performs the following actions in sequence:
- Prints the current date and time.
- Runs
apt-get update
to refresh the package list. - Runs
apt-get upgrade -y
to install available upgrades. - Runs
apt-get full-upgrade -y
to apply all upgrades, including those requiring removal of obsolete packages. - Runs
apt-get autoclean -y
to clean up outdated package files. - Runs
apt-get autoremove -y
to remove unneeded packages.
Clone this repository with:
git clone https://github.com/Geek-MD/raspiupdater.git
cd raspiupdater
- A Debian/Raspbian-based operating system.
- Superuser privileges (
sudo
).
Make the script executable:
chmod +x raspiupdater.sh
Run the script:
./raspiupdater.sh
Alternatively, run it with bash
:
bash raspiupdater.sh
To run the script automatically every Sunday and Wednesday at 3:00 AM, add the following line to your crontab:
0 3 * * 0,3 bash ~/raspiupdater/raspiupdater.sh > ~/raspiupdater/raspiupdater.log
You can edit the crontab with:
crontab -e
This will keep a log of each execution in raspiupdater.log
in your home
directory.
- Run this script periodically to keep your system updated and clean.
- Monitor the log file to verify successful updates.
This script requires an internet connection and may take several minutes depending on the number of available updates.