Operating System - HP-UX
1834492 Members
3389 Online
110067 Solutions
New Discussion

Re: how auto run my program when the hp_ux11.0 was booted?

 
SOLVED
Go to solution
westcamp_hu
Occasional Contributor

how auto run my program when the hp_ux11.0 was booted?

I want to auto run my program after the hp_ux11.0 system booted.How can I to do?please help.
westcamp_hu
4 REPLIES 4
Scott Van Kalken
Esteemed Contributor
Solution

Re: how auto run my program when the hp_ux11.0 was booted?

This is relatively easy to do.


You make a script that starts up your program.

this goes into /sbin/init.d/

I usually take a copy of the "lp" script in this directory, rename it, and use that as an example.

Next you place a file in /etc/rc.config.d the same name as your startup script.

This file has one thing in it VARIABLE=1

the name variable is usualloy also the same as your startup script name.

Then you link it to a run level
Michael Tully
Honored Contributor

Re: how auto run my program when the hp_ux11.0 was booted?

Hi,

You need to set a script into a run-level
on your server and have it linked to a
executable script that starts your application.

e.g.

/sbin/init.d/dbstart
has a link from /sbin/rc3.d/S880dbstart
The script should executable. You should also
have a termination script in /sbin/init.d/rc2.d
depending on your application. Mine is /sbin/rc2/K100dbstop, which links to the same script, for termination of the database.
You also should use a config file say in /etc/rc.config.d/dbstart so that the application start/stop can be changed. Use one of the examples from your system. You will see that this part is easy


#!/sbin/sh
#
# @(#) $Revision: 72.11 $
#
# NOTE: This script is not configurable! Any changes made to this
# script will be overwritten when you upgrade to the next
# release of HP-UX.
#
# WARNING: Changing this script in any way may lead to a system that
# is unbootable. Do not modify this script.

#
# This will START/STOP Informix Instances at Start-up / Shutdown
#

# 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.

# 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')
echo "Starting the subsystem"
;;

'stop_msg')
echo "Stopping the subsystem"
;;

'start')

# source the system configuration variables
if [ -f /etc/rc.config.d/dbstrstp ] ; then
. /etc/rc.config.d/dbstrstp
else
echo "ERROR: /etc/rc.config.d/dbstrstp defaults file MISSING"
fi

# Check to see if this script is allowed to run...
if [ "$DBINST" -eq 1 ]; then
/usr/local/bin/dbstart -all

else
rval=2
fi
;;

'stop')

# source the system configuration variables
if [ -f /etc/rc.config.d/dbstrstp ] ; then
. /etc/rc.config.d/dbstrstp
else
echo "ERROR: /etc/rc.config.d/dbstrstp defaults file MISSING"
fi

# Check to see if this script is allowed to run...
if [ "$DBINST" -eq 1 ]; then
/usr/local/bin/dbstop -all

else
rval=2
fi
;;

*)
echo "usage: $0 {start|stop|start_msg|stop_msg}"
rval=1
;;
esac

exit $rval

HTH
~Michael~
Anyone for a Mutiny ?
Michael Tully
Honored Contributor

Re: how auto run my program when the hp_ux11.0 was booted?

Hi,

Because my typing is very ordinary it is recommended to have your numbers so that they add up to 1000. Usually the high numbers are used to start, i.e. 880 and the low numbers for termination, i.e. 120
So, an example /sbin/rc3.d/S880dbstart pairs off with /sbin/rc2.d/K120dbstop. You can use the variable number as Scott has suggested as a good guide for your config file, /etc/rc.config.d/dbstart

Cheers
~Michael~
Anyone for a Mutiny ?
Gnananandhan
Frequent Advisor

Re: how auto run my program when the hp_ux11.0 was booted?

Hi,
What micheal says is the right procedure. If you plan only to start and not to stop you can do this.

1.)go to /sbin/rc3.d
2.)select the Sxxx file which is having a highest numeric value(xxx)
3.) edit that file and add in your commends & comments at the last line.

This will ensure the program is run always whenever the system is restarted.

Regards,
Gnana A.
If there is a better way to do it, find it !