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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With