Currently, to get things up to date on my Raspberry Pi, I have to type in
sudo apt-get update and
sudo apt-get upgrade. Is there a way to set it up to automatically do this? I am running Raspbian Jessie.
instead of a manual cron, you can install
unattended-upgrades, which is useful to ensure the latest kernels are installed. It's mostly designed for security.
apt-get install unattended-upgrades
There are some bits that can be adjusted/configured, but the default is fine.
In a terminal, type:
To access a root-level prompt. Then, run:
To begin editing your crontab, a table of tasks to run automatically at a given time. It will open in your preferred text editor. Modify it to include the following lines:
0 7 * * 1 apt update && apt upgrade -y
To automatically update and upgrade your apps at 7AM every Monday. Read-up on crontab to see how to adjust to your liking.
You can install and configure cron-apt. Install it by doing the following:
apt-get install cron-apt
the main configuration file is /etc/cron-apt/config
One thing I add to my configuration is:
this will send an email every time it runs, not only if it encounters an error.
Note that the default setup will not automatically install the updates (there are some good reasons to not do this), but you can config it to do so. One advantage this program provides over a simple cron solution is that it gives you control over what gets installed (only download new packages, install security updates or install all updates).
To set the time it runs edit the /etc/cron.d/cron-apt file.
You can find more info and config options here
The package includes very good documentation, however it is gzipped. To extract the file:
- create a directory to work in - mkdir cron-apt_documentation
- change to the new directory - cd cron-apt_documentation
- copy the compressed file - cp /usr/share/doc/cron-apt/README.gz . (note the trailing dot)
- uncompress the file - gunzip README.gz
- read the file - cat README | less