How can I use cron-apt to download and install updates between midnight and 5am?

6,967

Actually the documentation of cron-apt is pretty thorough. You can find the documentation and examples in /usr/share/doc/cron-apt. If you don't intent to read it, you can easily just set up a root cronjob yourself (without using cron-apt).

You can open the crontab of the root-user with sudo crontab -e. Now just add something like this:

# m h  dom mon dow   command
0   1  *   *   *     /usr/bin/apt-get update && /usr/bin/apt-get -y dist-upgrade

Make sure there is an empty line at the end of the file and save it. The dist-upgrade makes sure, that upgrade go through, even packages need to be removed to install upgrades to other packages. If you don't want to risk that, leave it at upgrade. If you add the -d option to the upgrade command, packages will only be downloaded and not installed. Check out man apt-get for more options.

Share:
6,967

Related videos on Youtube

rudivonstaden
Author by

rudivonstaden

Updated on September 18, 2022

Comments

  • rudivonstaden
    rudivonstaden almost 2 years

    I have capped data which is essentially free between midnight and 5am. As a result, I would like to set Ubuntu to automatically download updates over that time. It seems that cron-apt is what I need, but the documentation and syntax is sketchy and unintuitive. Can anyone tell me how to use it to schedule downloads?

    It can install the updates at the same time as far as I'm concerned, but that's not such a big issue - I can run those at a later stage.