Operating System - HP-UX
1834144 Members
2054 Online
110064 Solutions
New Discussion

Re: Not able to run script in init.d

 
titu
Regular Advisor

Not able to run script in init.d

hi all ,

i created a script but not able to initialize those ?

# root@dbsrv12 /sbin/init.d [3]cat omsagent #!/sbin/sh # # # Automated script to start and stop OMS 10g Intelligent Agent #

# Allowed exit values:
# 0 = success; causes "OK" to show up in checklist.
# 1 = failure; causes "FAIL" to show up in checklist.
# 2 = skip; causes "N/A" to show up in the checklist.
# Use this value if execution of this script is overridden
# by the use of a control variable, or if this script is not
# appropriate to execute for some other reason.
# 3 = reboot; causes the system to be rebooted after execution.
# 4 = background; causes "BG" to show up in the checklist.
# Use this value if this script starts a process in background
mode.

# Input and output:
# stdin is redirected from /dev/null
#
# stdout and stderr are redirected to the /etc/rc.log file
# during checklist mode, or to the console in raw mode.

PATH=/usr/sbin:/usr/bin:/sbin
export PATH

# NOTE: If your script executes in run state 0 or state 1, then /usr might
# not be available. Do not attempt to access commands or files in
# /usr unless your script executes in run state 2 or greater.
Other
# file systems typically not mounted until run state 2 include
/var
# and /opt.

rval=0

# Check the exit value of a command run by this script. If non-zero, the # exit code is echoed to the log file and the return value of this script # is set to indicate failure.

set_return() {
x=$?
if [ $x -ne 0 ]; then
echo "EXIT CODE: $x"
rval=1 # script FAILed
fi
}
case $1 in
'start_msg')
# Emit a _short_ message relating to running this script with
# the "start" argument; this message appears as part of the checklist.
echo "Starting OMS 10g Intelligent Agent"
;;
'stop_msg')
# Emit a _short_ message relating to running this script with
# the "stop" argument; this message appears as part of the checklist.
echo "Stopping OMS 10g Intelligent Agent"
;;
'start')
# Execute the commands to start your OMS Agent subsystem
echo "Starting OMS 10g Intelligent Agent"
su - oracle -c "/u01/app/oracle/product/agent10g/bin/emctl start agent"
set_return
;;
'stop')
# Execute the commands to stop your subsystem
echo "Stopping OMS 10g Intelligent Agent"
su - oracle -c "/u01/app/oracle/product/agent10g/bin/emctl stop agent"
set_return
;;
*)
echo "usage: $0 {start|stop}"
rval=1
;;
esac
exit $rval

# ------- End of script ---------


i am using this script in init.d but it's not running on reboot while when i try to run the same manually i am able to start the service.

thanks in advance.

titu
3 REPLIES 3
Patrick Wallek
Honored Contributor

Re: Not able to run script in init.d

Do you have links to the /sbin/init.d script in /sbin/rc3.d? Go to /sbin/rc3.d and do an 'll'. You will notice that there are S* and K* scripts which are links back to scripts in /sbin/init.d.

The 'S*' scripts are run at startup and the K* scripts are run at shutdown. The numbers after the S and the K in the link name determine the order in which they are run. S950start will run before S999*, etc. The common convention is for the numbers in the S* and K* links for a particular script to add up to 1000.

So if you want this script to run as part of the run level 3 startup you should do:

# cd /sbin/rc3.d
# ln -s /sbin/init.d/omsagent S980omsagent

And to have it shutdown when you do a shutdown:

# cd /sbin/rc3.d
# ln -s /sbin/init.d/omsagent K020omsagent
titu
Regular Advisor

Re: Not able to run script in init.d

Patrick thanks for response , i will follow the steps and will update in thread.

Titu
titu
Regular Advisor

Re: Not able to run script in init.d

it helped a lot

thanks for reply.

titu