Debian Admin

Debian/Ubuntu Linux System Administration Tutorials,Howtos,Tips

  • RSS Subscribe

    subscribe to the Debian Admin RSS feed
  • Sponsors



  • Categories

  • Sponsors

  • Support DebianAdmin

    Amount $:
    Website(Optional):


  • Meta

  • Archives



Automatic update of packages using cron-apt

Posted by Admin on October 6th, 2006

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

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

MAILON=”always”

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.
MAILTO=”updates@domain.com”

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.

example:-

# 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

#!/bin/bash
#
# 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
fi
fi

  • Share/Bookmark

One Response to “Automatic update of packages using cron-apt”

  1. joe Says:

    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).

    So, how can i get it to go beyond the default and get it to do the install too? that’s far more useful to discuss here than the email options you bother explaining…

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>