Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 3
    Not sure the answer, but it'll boil down to environmental. As a general point on problems like these, you might try to break it apart into separate pieces in the same temporary/test/one-time script, echo plenty of return codes and don't suppress any errors. For example, take the subshell commands, execute each individually then echo $? after each and then once again altogether as a subshell and echo $? that as well. Something will jump out at you. You can schedule that as a one time cronjob and examine the email generated. Commented Jun 7, 2013 at 12:22
  • 1
    Is it the same shell in both cases? Try this: ( set -o noclobber; echo $? > "$ecfile"; shopt > "$debugfile"; echo "$SHELL";) Commented Jun 7, 2013 at 14:20
  • 1
    Just explicitly force a shell through a shebang line ( #!/bin/bash ) or by using bash /your/path/and/file) Commented Jun 7, 2013 at 14:22
  • 1
    Post the full script. Also, add set -x at the top of the script just below the #! line, run the script from the command line, run the script from cron, and post both resulting traces. Commented Jun 7, 2013 at 22:30