The updated infrastructure management interface

How to Set Up Cron Notifications to Email on Ubuntu 20.04

Joe Harris
February 27, 2021

We have already covered setting up automatic scheduled tasks using cron in Ubuntu 20.04. In this tutorial we will look at an additional handy feature and set up sending Cron notifications to email.

Server preparation

First, you need to configure your server to be able to send emails. You can go through the steps in this tutorial — Postfix configuration as a Send-Only SMTP Server.

Following the instructions in the first two steps should be sufficient for our purposes. However, some mail servers will put unencrypted emails in the Spam folder or reject altogether.

Therefore, if you will not receive notifications as a result of following the steps in this guide, try checking your junk mail folder and enabling SMTP encryption (step 4 of the Postfix configuration guide).

To check the server’s email logs, see:

cat /var/log/mail.log

Set up sending Cron notifications to email

Open the Cron configuration file.

crontab -e

Place this config in it. Replace the email address with yours.

* * * * * echo "Message from Ubuntu cron"

Cron email notification
Screenshot 1. Cron email notification.
Start Your Cloud Journey Migration made simplified. Take the first step right now.
We use cookies to provide our services and for analytics and marketing. To find out more about our use of cookies, please see our Privacy Policy. By continuing to browse our website, you agree to our use of cookies.