Why does using set -e cause my script to fail when called in crontab

Posted by SDGuero on Stack Overflow See other posts from Stack Overflow or by SDGuero
Published on 2010-05-19T23:27:56Z Indexed on 2010/05/19 23:30 UTC
Read the original article Hit count: 99

Filed under:
|
|

I have a bash script that performs several file operations. When any user runs this script, it executes successfully and outputs a few lines of text but when I try to cron it there are problems. It seems to run (I see an entry in cron log showing it was kicked off) but nothing happens, it doesn't output anything and doesn't do any of its file operations. It also doesn't appear in the running processes anywhere so it appears to be exiting out immediately.

After some troubleshooting I found that removing "set -e" resolved the issue, it now runs from the system cron without a problem. So it works, but I'd rather have set -e enabled so the script exits if there is an error. Does anyone know why "set -e" is causing my script to exit?

Thanks for the help,
Ryan

© Stack Overflow or respective owner

Related posts about bash

Related posts about scripting