hi all,
I have created the following script which runs very well when it is executed alone.
This script is to be run by a third party application (Oracle clusterware).
The script (when is run by the application) doesn't successfully execute the xclock command. It even doesn't return the $USER variable.
Following is what I got:
Code:
#
# Copy of the script
#
[oracle@rac1 ~]$ cat /u01/crs/crs/script/crsclock_action.scr
#!/bin/bash
# start/stop/check script for xclock example
# the script assumes xclock is there
# and DISPLAY variable is set
APP=/usr/X11R6/bin/xclock
BIN_NAME=xclock
echo `date +"%M:%S"` $0 $* $$>>/tmp/mylog.log
PID1=`ps -ef | grep $BIN_NAME | grep -v grep | grep -v xclock_app | awk '{ print $2 }'`
case $1 in
'start')
if [ "$PID1" != "" ]
then
status_p1="running"
else
if [ -x $APP ]
then
${APP} &
PID1=`ps -ef | grep $BIN_NAME | grep -v grep | grep -v xclock_app | awk '{ print $2 }'`
echo `date +"%M:%S"` $* $PID1 $USER>>/tmp/mylog.log
status_p1="started"
else
echo `basename $0`": $APP: Executable not found"
fi
fi
echo "$APP: $status_p1"
;;
'stop')
if [ "${PID1}" != "" ]
then
kill -9 ${PID1} && echo "$APP killed"
else
echo "$BIN_NAME: no running Process!"
fi
;;
'check')
if [ "$PID1" != "" ]
then
echo "running"
exit 0
else
echo "not running"
echo `date +"%M:%S"` $0 $* "ERR">>/tmp/mylog.log
exit 1
fi
;;
*)
echo "Usage: "`basename $0`" {start|stop|check}"
;;
esac
#
# test output of the script when run alone
#
[oracle@rac1 ~]$ xhost +
access control disabled, clients can connect from any host
[oracle@rac1 ~]$ /u01/crs/crs/script/crsclock_action.scr start
/usr/X11R6/bin/xclock: started
# here I can see the xclock poping up in the screen
[oracle@rac1 ~]$ cat /tmp/mylog.log
44:11 /u01/crs/crs/script/crsclock_action.scr start 17694
44:11 start 17702 oracle
[oracle@rac1 ~]$ /u01/crs/crs/script/crsclock_action.scr check
running
[oracle@rac1 ~]$ cat /tmp/mylog.log
44:11 /u01/crs/crs/script/crsclock_action.scr start 17694
44:11 start 17702 oracle
45:22 /u01/crs/crs/script/crsclock_action.scr check 18270
[oracle@rac1 ~]$ /u01/crs/crs/script/crsclock_action.scr stop
/usr/X11R6/bin/xclock killed
#
# output of log when the script is run by Oracle clusterware
#
#
# log file first is flushed
[oracle@rac1 ~]$ echo ""> /tmp/mylog.log
[oracle@rac1 ~]$ crs_start myClock
Attempting to start `myClock` on member `rac1`
Start of `myClock` on member `rac1` succeeded.
[oracle@rac1 ~]$
[oracle@rac1 ~]$ cat /tmp/mylog.log
48:14 /u01/crs/crs/script/crsclock_action.scr start 19557
48:14 start
48:19 /u01/crs/crs/script/crsclock_action.scr check 19660
48:19 /u01/crs/crs/script/crsclock_action.scr check ERR
48:20 /u01/crs/crs/script/crsclock_action.scr stop 19674
48:20 /u01/crs/crs/script/crsclock_action.scr start 19682
48:20 start
48:25 /u01/crs/crs/script/crsclock_action.scr check 19724
48:25 /u01/crs/crs/script/crsclock_action.scr check ERR
48:25 /u01/crs/crs/script/crsclock_action.scr stop 19733
48:25 /u01/crs/crs/script/crsclock_action.scr start 19741
48:25 start
48:30 /u01/crs/crs/script/crsclock_action.scr check 19783
48:30 /u01/crs/crs/script/crsclock_action.scr check ERR
48:30 /u01/crs/crs/script/crsclock_action.scr stop 19792
Note: the script is automatically re-excuted by Oracle clusterware when the 'check' command returns error and that's why the start 'command' appears multiple times in the log.
Any help is appreciated.