Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cron not sending email

Tags:

cron

I have installed PostFix and sendmail both, and then try to set cron for a python script and want to send an email by cron.

My cron schedule like:

[email protected]
*/2 * * * * python3 /var/test.py >> /var/log/test.log 2>&1

Still Cron is not sending any email.

Please help what i need to do more.

like image 836
shiva Avatar asked Sep 28 '17 06:09

shiva


People also ask

Why is my cron not working?

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 cron daemon email?

In some cases, we need to run specific tasks at pre-defined intervals. And, cron is a Linux task scheduler that ensures scripts run at specific times. It is mainly used to run backup scripts, log rotation, update file indexes, run custom scripts and so on.


1 Answers

Cron will send the STDOUT and STDERR from the script by email.

>> /var/log/test.log 2>&1

… but your script has redirected them both to a file so there isn't any data to send.

Remove the redirect if you want the data to appear in an email instead.

like image 178
Quentin Avatar answered Sep 29 '22 05:09

Quentin