News
3 new Serverspace GPT API Language Models available now!
JH
Joe Harris
February 27 2021
Updated July 18 2025

How to Set Up Cron Email Notifications on Ubuntu 20.04

Linux Maintenance Ubuntu

Using another OS?

Select the desired version or distribution.

We have already covered setting up automatic scheduled tasks using cron in Ubuntu 20.04.In this tutorial, we’ll show you how to configure Cron to send email notifications - a useful feature for monitoring automated tasks on Ubuntu 20.04.

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.

MAILTO="mail@domain-name.com"
SHELL=/bin/bash
HOME=/
* * * * * echo "Message from Ubuntu cron"
Cron email notification
Screenshot 1. Cron email notification.

Conclusion

Setting up email notifications for Cron jobs on Ubuntu 20.04 is a practical way to stay informed about the status of your scheduled tasks. By properly configuring your mail server (such as Postfix) and adjusting your crontab settings, you can receive timely alerts directly to your inbox. This helps with monitoring, troubleshooting, and ensuring your automated processes run smoothly. Remember to check your spam folder if emails don’t appear and consider enabling SMTP encryption for improved reliability. With these steps, managing Cron notifications becomes straightforward and effective.

FAQ: Cron Email Notifications on Ubuntu 20.04

  • Why am I not receiving Cron emails?
    Check your spam or junk folder first. Some mail servers may flag unencrypted emails as spam. Ensure your SMTP server is properly configured and consider enabling encryption as described in the Postfix setup guide.
  • How do I specify the recipient email for Cron notifications?
    In your crontab file (crontab -e), add the line:
    MAILTO="your-email@example.com"

    Replace the email address with the one you want to receive notifications.

  • Can I customize the content of Cron email notifications?
    Yes. The email content is usually the output of your Cron job commands. You can customize what the job echoes or logs to control what gets sent.
  • What if I want to disable email notifications for a specific Cron job?
    You can redirect the output of that specific job to /dev/null like this:
    * * * * * /path/to/command > /dev/null 2>&1
  • How do I check if my mail server is sending emails correctly?
    Review the mail logs using:
    cat /var/log/mail.log

    This will help you diagnose any sending issues.

Vote:
5 out of 5
Аverage rating : 5
Rated by: 1
33145 North Miami, FL 2520 Coral Way apt 2-135
+1 302 425-97-76
700 300
ITGLOBAL.COM CORP
700 300
We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.