Use cron-apthttp://www.aliyun.com/zixun/aggregation/18862.html "> Automatic update package
The package cron-apt is designed to automatically update the package list and download the updated package. Therefore, it mainly uses the command
APT Upgrade
and
Apt dist-upgrade-d
。
Install Cron-apt
You can get cron-apt from universe repositories.
Make Cron-apt Run regularly
To make Cron-apt run regularly, create a link to/etc/cron.daily or/etc/cron.weekly
sudo ln-s/usr/sbin/cron-apt/etc/cron.daily
CRON-APT only download new packages, you need to run them manually to install them
sudo apt dist-upgrade
* If you are using CRON-APT, you do not need to refer to the following steps.
Use cron and apt weekly automatic upgrade packages
Warning: New or additional errors may occur on any system change. Make sure to back up your data and settings! Bear the consequences of using this document yourself. Regularly updating your Ubuntu (or Debian) packages can help strengthen system security and troubleshoot system vulnerabilities. This howto guide describes how to install a cron job on your system to update your system every week and remove any packages that are not used after installation. This document assumes that your system is based on the most common or most common broadband environment, not dial-up, Internet connection.
New Recurring Cron Job file
First you need to create a new cron job file. You can use a simple text editor to create and save to your home folder. In the Ubuntu system, open the Application > Attachment > Text Editor. In the editor, enter the following:
#!/bin/bash
APT Update
Apt upgrade-y
Apt AutoClean
Then save the file and name it like "AUTOUPDT". The default folder should be your home folder, but make sure. (The following steps assume that the file is saved in your home folder.) )
Move cron job files to cron.weekly
Now that you have created a cron job file, you need to move it to a cron weekly folder to make it run automatically every week. To do this, you need to open a command-line terminal. In Ubuntu, click Application > System Tools > Terminals. Now you should be able to see the terminal prompt. Enter "LS" at the prompt and press ENTER (some keyboard is the return key). You should be able to see the new file "AUTOUPDT" in the list.
user@system:~ $CD ~
user@system:~ $ls
Now that we have confirmed that the file exists, we need to move it to the correct folder. Move the file by entering the following command after the prompt:
user@system:~ $sudo MV Autoupdt/etc/cron.weekly
(You should enter your sudo password correctly, that is, your personal password.) Now we need to confirm that the file has been moved to a cron folder. After the prompt, enter:
user@system:~ $CD/etc/cron.weekly
user@system:~ $ls
You should be able to see "AUTOUPDT" in the list. (if not, try the previous move command again.) )
Make a cron job file executable
Now that the file is created and ready to run by Cron every week, we also need to make the file executable so that it can be run. Because you are already in the Cron.weekly folder, you only need to enter the command:
user@system:~ $sudo chmod 755 AUTOUPDT
(You'll need to confirm your password again.) )
Complete
The task completes because the file is executable. The cron job runs and upgrades your source list weekly (check for updatable packages), discovers and upgrades packages as needed, and cleans up old, unused packages. You can still use the new software Package Manager or command apt, but now you can take a break because it's automatically updated every week.