Email notification with cron-apt via mailx

1. Install and configure cron-apt

1
# apt-get install cron-apt bsd-mailx ssmtp    # Or msmtp

We want only be notified of new updates. We want not to install them automatically. All settings are optimal for this action by default. And the cronjob will also run every day 4am by default. All you have to change in /etc/cron-apt/config is the following:

1
2
MAILTO="user@example.com"
MAILON="upgrade"     #to only be notified if updates are avaiable

 

2. Be notified

To be notified via mailx, you have to copy the 9-notify from examples to actions.d and edit them.

1
# cp /usr/share/doc/cron-apt/examples/9-notify /etc/cron-apt/action.d/
1
2
# vi /etc/cron-apt/action.d/9-notify
-q -q --no-act upgrade MAILON=user@example.com

 

3. Configure ssmtp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=someuser@thebc.ch

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=mailbox.thebc.ch         # Or the IP-address

# Where will the mail seem to come from?
#rewriteDomain=

# The full hostname
hostname=thisserver.thebc.ch

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES

 
4. Check your installation

To check if all is working as you expect run:

1
# cron-apt -s

About missing_link

Nietzsche is dead.
This entry was posted in Debian, Linux, Software. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.