Ubuntu 14.04lts with Perl 5.18.2.
This is a special case where Google did not help me. I do not want to turn off email for all cron jobs, I have about 15 jobs in my crontab. I need to see the emails cron sends me if there are errors.
This one job is a special case for which I need a solution. I have a bash script in my crontab which calls a perl script which is setup to check for email every 5 minutes. (It is not possible for me to setup a full MTA.) If there is no email the script does not output anything to STDOUT or STDERR yet cron still sends me a blank email with the full path of the bash script in the subject.
- I want cron and the Perl script to send me email if the perl script finds email and processes it, including if there are errors.
- I don't want cron to send me a blank email if there is no output from the Perl script because no email was found. The script runs every 5 minutes.
Anyone have any ideas?
EDIT: Confirmed. It was a stray newline that was my problem. Problem solved. Cron does not send an email if there is no output. Thank you! Your comment helped.
It was a stray newline causing the blank email every 5 minutes.
Cron only sends an email if the cron job/program run has output. My output was a newline, which of course, I couldn't see in Alpine, but it was there. I found the newline that my program was printing and removed it.
Now I design my cron programs to never output anything unless it gets past the parameter checking.