Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mailto crontab doesn't work

Tags:

I'm running a script on my mybookworld(NAS) via crontab every day. And it would be nice if it could send me everyday an email report with the output of the script.

So I looked at MAILTO in crontabs, but it doesn't send me anything at all. The script ran correctly at the right time, but there was no email. This is my crontab:

~ # crontab -l [email protected]  0 0 * * * python /root/erepCrawler/src/main.py 

I've written a "smaller" crontab for testing reasons:

[email protected] * * * * * echo "blaah" 

This should send me every minute an email with "blaah" as the body. If I'm wrong please correct me.

Is there another package needed for sending mails with crontab? sendmail is installed in /opt/sbin/sendmail.

like image 377
Simon Lenz Avatar asked Mar 25 '11 17:03

Simon Lenz


People also ask

Why my crontab is not working?

Why is crontab not working in your system? Crontab might fail for a variety of reasons: The first reason is that your cron daemon might not be working for any reason, resulting in your crontab failing. There also exists a possibility that your system's environment variables are not settled correctly.

What is mailto in cron?

MAILTO="" Otherwise email is sent to the owner of the crontab.

How do I find my cron email?

On CentOS, my cron output gets "mailed" to /var/spool/mail. See it by running less $MAIL if you want to see cron output for the current user or less /var/spool/mail/root if you want to see cron output for commands running as root.

How do I check if crontab is working?

Method # 1: By Checking the Status of Cron ServiceRunning the “systemctl” command along with the status flag will check the status of the Cron service as shown in the image below. If the status is “Active (Running)” then it will be confirmed that crontab is working perfectly well, otherwise not.


2 Answers

It should work in the cron with following modifications:

MAILTO="[email protected]" * * * * * echo blaah 

works on my server, just tested.

like image 102
Scherbius.com Avatar answered Nov 04 '22 08:11

Scherbius.com


after spending hours debugging why this wasn't working with nullmailer on my Debian box, I discovered I had a filter at gmail sending everything from cron to "All Mail" without going through my inbox... just something to check.

like image 26
jcomeau_ictx Avatar answered Nov 04 '22 10:11

jcomeau_ictx