I have a shell script that I've scheduled to run via cron.daily once a day. It usually runs for about 30-50 minutes, then dies without completing. It runs fine when run from the command line. No email is sent from cron, even though the script normally produces output. The line that usually fails is a find command that exec's a lame MP3 encoder. After processing somewhere between 1000-3000 files, it just stops. Reproducible: Always Steps to Reproduce: 1. Put runConvert.sh script in /etc/cron.daily directory 2. Wait for it to run 3. Actual Results: The script runs (I can see it executing in 'ps'), but exits after 20-50 minutes with no explanation. Nothing in /var/log, and no email sent. Expected Results: Should finish normally and email the script output to root. Installed packages: sys-process/vixie-cron 4.1-r8 mail-mta/ssmtp 2.61 /etc/cron.daily/runConvert.sh --------------------------------------- if [ $# -eq 0 ]; then sd=`date -d"-60 days" +%Y%m%d` else sd=$1 fi echo Starting step 1 on $sd find /home/mg/MGC/${sd} -name '*.wav' -type f -exec normalize -q {} \; echo Starting step 2 find /home/mg/MGC/${sd} -name '*.wav' -type f -exec bash -c 'lame {} `dirname {} `/`basename {} .wav`.mp3 -h -b16 --silent' \; echo Starting step 3 find /home/mg/MGC/${sd} -name '*.mp3' -type f -exec chown samba {} \; echo Starting step 4 find /home/mg/MGC/${sd} -name '*.mp3' -type f -exec chgrp users {} \; echo Starting step 5 find /home/mg/MediaguideCache/${sd} -name '*.mp3' -type f -exec chmod 660 {} \; echo Done converting directory ${sd} to MP3. Please delete WAVs if counts match. echo MP3: `find /home/mg/MGC/${sd} -name '*.mp3' -type f | wc -l` echo WAV: `find /home/mg/MGC/${sd} -name '*.wav' -type f | wc -l` echo SNG: `find /home/mg/MGC/${sd} -name '*.sng' -type f | wc -l`
I think I may have some more info on this bug. It may be related to ssmtp timing out while waiting for the script to complete. I've looked through a bit of the ssmtp code, and it appears to have a MAXWAIT constant that is set to 10 minutes per command line. I'm not sure what happens when it hits this MAXWAIT though. Can anyone enlighten me? Is there any workaround for this?
More info: If I make the find command that executes lame, output a line for each file, the script finishes successfully. This leads me to think that it is not a problem with cron, but with ssmtp timing out. Here's what I changed the find command to: find /home/mg/MGC/${sd} -name '*.wav' -type f -exec bash -c 'echo {} ; lame {} `dirname {}`/`basename {} .wav`.mp3 -h -b16 --silent' \; Just the "echo {}" in this line made everything work OK. Now that I know what the problem is, I would like to get around printing one line for each file processed since there are upwards of 3000 files I'm processing. So in conclusion, this probably isn't a cron problem but a ssmtp problem.
re-assigning to ssmtp maintainers
This is how ssmtp works: * Parses the command-line and sets some vars * Opens the network connection to the server and sends the greeting, thus starting the smtp session. * Then sends the MAIL FROM and RCPT TO commands and writes a 'Received by:' header. * Now starts reading from stdin and writing to the socket here it sets an alarm for 5 minutes. This means that if there is no input in 5 minutes then it emits SIGALRM and dies. I don't know if vixie-cron should call ssmtp BEFORE having the whole output of the command; I'd say NO. But it does, so you have some workarounds: 1) Use another mail client (there are several in the tree) 2) Maybe do 'echo -n .' everytime a file is proccessed thus making ssmtp happy and not bloating your report a lot. Sorry but this is a ->WONTFIX. Cheers, Ferdy