I have a cron job running a script which takes about 6 hours to finish. The problem is that cron is not mailing me the output of that job, and I would like it to.
I have it in /etc/crontab and it's something like:
0 * * * * myuser /usr/local/bin/my-script
Yes, this run's it every hour, but there is a lock-file in the script, so if the previous run didn't finish, the new run of the script will quit immediately without doing anything.
The system is Debian 5.0 'lenny', and the MTA is Postfix.
If the job is killed (with "kill $PID") early during its run, then I do get an e-mail with the output of the job. Also if I modify the script to do 10 times less stuff, then I also do get an e-mail. Its only if the script is running for some hours I do not get an e-mail at all.
Relevant lines of ps afx
a short time after the cron job starts:
8222 ? Ss 0:04 /usr/sbin/cron
13265 ? S 0:00 \_ /USR/SBIN/CRON
13297 ? Ss 0:00 \_ /bin/bash /usr/local/bin/my-script
13395 ? S 0:16 | \_ /usr/bin/python /usr/local/bin/some-script.py
17065 ? S 0:00 \_ /usr/sbin/sendmail -i -FCronDaemon -oem myuser
17066 ? S 0:00 \_ /usr/sbin/postdrop -r
So it seems that the MTA is already called when the cron job starts, not when it finishes. Can that be related to the problem? Might it be possible that Postfix doesn't like postdrop
running so long, and it times-out or something? How can I solve the issue - I need to have the output e-mailed to me.