Originally Posted by chrism01
Actually, he didn't, he's got the specified shell as the first line of the script which is fine.
on my system /bin/sh
is a link to bash - it should be the standard. But you don't know that for sure. It could be bourne shell or korn shell or C shell and then you'll get into trouble if you request a specific shell. That's why I recommend to define exactly, which shell to use.
Another point: Even if you define the shell at the shebang line - if you call the script using sh /path/to/script
, the calling shell executes the script and doesn't take care of the shebang line:
jan@jack:~/tmp> cat bash.sh
for ((i=1;i<4;i++)); do
jan@jack:~/tmp> sh ./bash.sh
jan@jack:~/tmp> ksh ./bash.sh
./bash.sh: syntax error: `((' unexpected
So, if the cron environment doesn't find your expected shell first in the path, you'll get into trouble again.