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

3 Responses 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…

  2. Dennis Johansen Says:

    Yes, I’m with Joe and his polite critic on this issue. Would have been better with small example for the script to actually download and upgrade the box. The mail issue is self explained in the config file, while the explanation of mode to install downloaded packages isn’t?

    Anyone out there who’s using this tool?

  3. Dennis Johansen Says:

    Anyone who can help me getting this tool to do the install of the downloaded packages?

    Please see the email notification from yesterday - Apparently the tool is in download mode - how to set it to download and install mode?

    CRON-APT RUN [/etc/cron-apt/config]: Thu Jan 14 04:00:01 CET 2010
    CRON-APT SLEEP: 204, Thu Jan 14 04:03:25 CET 2010
    CRON-APT ACTION: 0-update
    CRON-APT LINE: /usr/bin/apt-get update -o quiet=2
    CRON-APT ACTION: 3-download
    CRON-APT LINE: /usr/bin/apt-get autoclean -y
    Reading package lists…
    Building dependency tree…
    Reading state information…
    Del libssl0.9.8 0.9.8g-15+lenny5 [2975kB]
    Del openssl 0.9.8g-15+lenny5 [1036kB]
    CRON-APT LINE: /usr/bin/apt-get dist-upgrade -d -y -o APT::Get::Show-Upgraded=true
    Reading package lists…
    Building dependency tree…
    Reading state information…
    The following packages will be upgraded:
    libkrb53 libssl0.9.8 openssl
    3 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    Need to get 4012kB/4493kB of archives.
    After this operation, 0B of additional disk space will be used.
    WARNING: The following packages cannot be authenticated!
    libssl0.9.8 libkrb53 openssl
    Authentication warning overridden.
    Get:1 http://security.debian.org lenny/updates/main libssl0.9.8 0.9.8g-15+lenny6 [2975kB]
    Get:2 http://security.debian.org lenny/updates/main openssl 0.9.8g-15+lenny6 [1036kB]
    Fetched 4012kB in 8s (490kB/s)
    Download complete and in download only mode

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>