On Sun, Apr 15, 2012 at 10:45 AM, Herring Dave - dherri < Dave.Herring@xxxxxxxxxx> wrote: > 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 :-) > WOT = Wide Open Throttle Sometimes applies to Oracle I guess. > 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" > exit 2 > fi > > There are better methods for doing this. Following is a function that creates a PID file and uses it for locking. Stale locks are handled. a possible issues with this - not useful as is on cluster, as other nodes could run the script. Anyway, it may be of some use. Jared Still Certifiable Oracle DBA and Part Time Perl Evangelist Oracle Blog: http://jkstill.blogspot.com Home Page: http://jaredstill.com ==== script ===== 9:49-poirot:ts20:jkstill-22 > expand -t3 locktest.sh : LOCKFILE=/tmp/testlock.lock function script_lock { typeset MY_LOCKFILE MY_LOCKFILE=$1 # remove stale lockfile [ -r "$MY_LOCKFILE" ] && { PID=$(cat $MY_LOCKFILE) ACTIVE=$(ps --no-headers -p $PID) if [ -z "$ACTIVE" ]; then rm -f $MY_LOCKFILE fi } # set lock if (set -o noclobber; echo "$$" > "$MY_LOCKFILE") 2> /dev/null; then trap 'rm -f "$MY_LOCKFILE"; exit $?' INT TERM EXIT return 0 else echo "Failed to acquire $LOCKFILE. Held by $(cat $LOCKFILE)" exit 1 fi } function script_unlock { rm -f "$LOCKFILE" trap - INT TERM EXIT } script_lock $LOCKFILE echo press '<ENTER>...' read dummy script_unlock -- //www.freelists.org/webpage/oracle-l