I realize this is way off topic (probably should be titled "WOT:...") for Oracle but #1, I don't currently belong to any good linux/redhat forums and #2, the issue found was from an Oracle maint. script :-)
Anyway, I'm on a RHEL 4.6 server (2.6.9-67.0.22.ELlargesmp) and noticed a given DBA maint script wasn't running. It turns out that the only difference between when it last ran and now is someone changed the shell to be "bash" -> #!/bin/bash vs. #!/bin/ksh. The script has a little if-test to start with, used as a way to determine if a previous iteration of the job is still running:
if [ `ps -ef|grep -cw $0` -gt 3 ]; then
echo "$0 is already running"
The problem is that when this "ps ..." command stream is run within an if-test, it returns a value 1 higher than under "ksh". So when run out of cron it returns 4 under "bash" and 3 under "ksh". I added "set -x" right before this command and here are the results:
+ grep -cw /home/test.sh
+ [ 3 -gt 3 ]
++ ps -ef
++ grep -cw /home/test.sh
+ '[' 4 -gt 3 ']'
This change only happens when running that command stream as part of an if-test. So "ps -ef|grep -cw $0" returns "3" but "if [ `ps -ef|grep -cw $0` -gt 3 ]" evaluates to "4". Am I interpreting this correctly in saying that bash forks another process when evaluating a command as part of an if-test while ksh does not? Is there a more general way of explaining this difference is shell processing?
EML [email protected]
1501 Opus Pl, Downers Grove, IL 60515, USA
The information contained in this communication is confidential, is intended only for the use of the recipient named above, and may be legally privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please resend this communication to the sender and delete the original message or any copy of it from your computer system. Thank you.