Q. How do I force apt-get to send me email when upgrades or security updates available under Debian or Ubuntu Linux? Do I need to write a shell script which generates a mail with a list of all packages currently pending an upgrade?

A. No you don’t have to write a shell script. You need to use apticron command / script for notification. apticron is mainly intended for automatic notification of pending security updates but can also be used in many other situations where timely updates are neccessary.

Install apticron

Type the following command at a shell prompt:
# apt-get update
# apt-get install apticron

Configure apticron to send email notifications

The default coniguration file is located at /etc/apticron/apticron.conf. Open file using text editor:
# vi /etc/apticron/apticron.conf
You need to set email address to email the notification as follows:
My sample configuration file:

# apticron.conf
# set EMAIL to a list of addresses which will be notified of impending updates

# Set LISTCHANGES_PROFILE if you would like apticron to invoke apt-listchanges
# with the --profile option. You should add a corresponding profile to
# /etc/apt/listchanges.conf

# Set SYSTEM if you would like apticron to use something other than the output
# of "hostname -f" for the system name in the mails it generates
# SYSTEM="foobar.example.com"

# Set IPADDRESSNUM if you would like to configure the maximal number of IP
# addresses apticron displays. The default is to display 1 address of each
# family type (inet, inet6), if available.

# Set IPADDRESSES to a whitespace seperated list of reachable addresses for
# this system. By default, apticron will try to work these out using the
# "ip" command
# IPADDRESSES=" 2001:db8:1:2:3::1"

Save and close the file. /etc/cron.daily/apticron is the cron script for executing apticron daily and it will send you notfication when updates available.

Sample apticron email

Here is a sample email:

apticron report [Sun, 06 Jul 2008 07:07:23 +0000]

apticron has detected that some packages need upgrading on: 

	[ :: ]

The following packages are currently pending an upgrade:

	libpcre3 6.7+7.4-4


Package Details:

Reading changelogs...
--- Changes for pcre3 (libpcre3) ---
pcre3 (6.7+7.4-4) stable-security; urgency=high

  * Non-maintainer upload by the security team.
  * Apply patch from Tavis Ormandy to fix a heap overflow in the compiler,
    triggered by patterns which contain options and multiple branches

 -- Florian Weimer   Fri, 04 Jul 2008 21:15:19 +0200


You can perform the upgrade by issuing the command:

	aptitude dist-upgrade

as root on vip.clicklinux.org

It is recommended that you simulate the upgrade first to confirm that
the actions that would be taken are reasonable. The upgrade may be 
simulated by issuing the command:

	aptitude -s -y dist-upgrade

-- apticron 

You will get an email when security updates released by Debian / Ubuntu security team. I also suggest subscribing to Debian email security update notification and Ubuntu Linux security notification via RSS or email.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 11 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
11 comments… add one
  • Ajayaghosh Jun 23, 2008 @ 4:58

    Redhat Linux: How to Send Automatic Email Notification in rhel-4 When Security Upgrades Available

  • budacsik Sep 20, 2008 @ 12:24

    Thanks for useful information

  • Bunnes Jul 31, 2009 @ 11:57

    How do I set things, that also the dist-uprades are installed automatically?

    Cheers! :)

  • gopi Nov 26, 2009 @ 15:41

    Can you guide me. How to a patch a linux service. send me some examples

  • ipog Dec 31, 2009 @ 5:18

    gopi: Send me $900 and I will send you an example. Send $1800, I will send you two. Special offer: three for only $2500. Act now, call the number on your screen, only 30 examples left!

  • Andrea Gaspardo Jan 17, 2010 @ 20:34

    “How do I set things, that also the dist-uprades are installed automatically?”
    Are you really sure???

  • paranic Feb 18, 2010 @ 23:37

    thats great! i was occasionally looking for a clean and good way to do this!

  • Kienan Apr 10, 2010 @ 4:08

    Your kindness and caring mean so much to me.

  • Azi Jul 23, 2010 @ 12:07

    Doesn’t work for some reason :( Not receiving any emails even though there are updates available. Does apticron require sendmail installed and configured. Any ideas?

  • Hank May 22, 2011 @ 16:03

    Thans, was very usefull for me!

  • Trinh Nguyen Oct 11, 2013 @ 6:28

    The cron script is in /etc/cron.d/apticron, not in /etc/cron.daily/apticron.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum