cron-apt Contains a tool that is run by a cron job at regular intervals. By default it just updates the package list and download new packages without installing. You can instruct it to run anything that you can do with apt-get (or aptitude).
It can optionally sends mail to the system administrator on errors, log to syslog or a separate log file.
Observe that this tool may be a security risk, so you should not set it to do more than necessary. Automatic upgrade of all packages is NOT recommended unless you are in full control of the package repository.
Install cron-apt in debian
#apt-get install cron-apt
This will complete the installation and now you need to configure cron-apt by default configuration file is /etc/cron-apt/config. you can specify when it runs in the /etc/cron.d/cron-apt file here is the default cron-apt file
# Regular cron jobs for the cron-apt package
# Every night at 4 o’clock.
0 4 * * * root test -x /usr/sbin/cron-apt && /usr/sbin/cron-apt
# Every hour.
# 0 * * * * root test -x /usr/sbin/cron-apt && /usr/sbin/cron-apt /etc/cron-apt/config2
# Every five minutes.
# */5 * * * * root test -x /usr/sbin/cron-apt && /usr/sbin/cron-apt /etc/cron-apt/config2
If you want to see the default cron-apt config file check here
You can leave all the default configurations one thing you need to enable is mailon option you can select when you want to receive emails.I prefer the following option
and other available options are
# Value: error (send mail on error runs)
# upgrade (when packages is upgraded)
# changes (mail when change in output from an action)
# output (send mail when output is generated)
# always (always send mail)
# (else never send mail)
You need to enter the email address to receive mails.
# The email address to send mail to.
One more thing is options in config file this is for General apt options that will be passed to all APTCOMMAND calls.
cron-apt will use the information available in /etc/apt/sources.list file to get the source package list.
# You can for example add an alternative sources.list file here.
OPTIONS=”-o quiet=1 -o Dir::Etc::SourceList=/etc/apt/security.sources.list”
This is one way of keeping your packages uptodate and some people they will use shell scripts to keep their packages uptodate.
If you are looking for simple shell script you can use the following one this script source is from here
Apt Update Script
# Cron Script – run from /etc/crontab or /etc/cron.daily
# Runs “apt-get update” and prints the output of a simulated
# dist-upgrade if new packages are found.
if [[ `apt-get update 2>&1 | grep Get` ]]; then
if [[ `apt-get –simulate dist-upgrade 2>&1 | grep Inst` ]]; then
apt-get –simulate dist-upgrade