1845896 Members
5030 Online
110250 Solutions
New Discussion

startup script

 
SOLVED
Go to solution
navin
Super Advisor

startup script

Hello,
I have a command to start the application and stop the application.Please let me know how can i create a startup and shutdown scripts with this command so that no need for doing this manually when system reboot or shutdown.please help.
Thanks Much
Learning ...
10 REPLIES 10
Pete Randall
Outstanding Contributor
Solution

Re: startup script

This process is documented in the "rc" man page. Have a look at that and let us know if you have specific suggestions.


Pete

Pete
Steven E. Protter
Exalted Contributor

Re: startup script

Shalom,

All lazy (good) sysadmins minimize their work here.

I generally take either /sbin/init.d/template or /etc/sbin/init.d/cron (or crond) and make a copy.

Then I modify this script to actually start/stop my new application.

Then I softlink to it in the /sbin/rc3.d directory for Start and /sbin/rc2.d dirctory for Kill

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Murat SULUHAN
Honored Contributor

Re: startup script

H Navin

You can use this file to create your own /sbin/init.d script

#!/sbin/sh

case $1 in
'start_msg')
;;
'stop_msg')
;;
'start')
;;
'stop')
;;
*)
echo "usage: $0 {start|stop}"
;;
esac
exit



And you must link this file to related /sbin/rc#.d/ directories to start and stop automatically


Best Regards
Murat
Murat Suluhan
Danny Petterson - DK
Trusted Contributor

Re: startup script

Hi!

First go to /sbin/init.d, thats where alle the start/stop-scripts are located. Take one, copy it to a name that suits its new use, and modify it to stop and start using the commands you already got. The stop/start-framework in these scripts are pretty easy to figure out, so that should be no big deal.

Then go to /sbin/rc3.d to create a link, which uses the script above to startup the application. It has to be called something like S<scriptname>, like S91testapp. Make it with:

ln -s /sbin/init.d/
If the application is dependent on some other startupscripts, please make sure that its S is highter.

Make the same in /sbin/rc2.d

in /sbin/rc1.d and /sbin/rc0.d you will make something like this, but here it should start with a "K", and is used for shutdown. If other applications are dependent on yours, make sure yours are shut down before those (lesser number).

That should be it.

Yours
Danny

James R. Ferguson
Acclaimed Contributor

Re: startup script

Hi :

In addition to the 'rc(1M)' manpages as Pete suggested, you can use this whitepaper:

http://docs.hp.com/en/934/startup.pdf

While written at the inception of 10.0, it applies to all current releases of HP-UX. The manpages for later releases document a return code of four (4) whereas the original whitepaper didn't.

Be sure to use the '/sbin/init.d/template' as a starting point. You need to provide the various cases for *your* startup script to interact correctly with the '/sbin/rc' driver code.

Regards!

...JRF...

Tim Nelson
Honored Contributor

Re: startup script

Let's not forget to change the CONTROL_VARIABLE in the copied template file and create a CONTROL_VARIABLE file in /etc/rc.config.d as well.

Ernesto Cappello
Trusted Contributor

Re: startup script

Hi Navin:

The rule is that the kill script goes in one run-level below that of the start script.

e.g If your start script is
/sbin/rc3.d/S910application then your kill script should be /sbin/rc2.d/K090application.

The other convention (though not a requirement) is that the 3 digits of both scripts should add to 1000. This almost always brings them up and down in the intended order. I have also implemented my applications to start in rc4.d and stop in rc3.d assuming the default run-level is 4.

Best Regards, Ernesto
navin
Super Advisor

Re: startup script

Hello All,
Could you please some one see the below script has any flaw...Thanks Much

# more apache
#!/sbin/sh

case $1 in
'start_msg')
echo "Start http server"
;;
'stop_msg')
echo "Stop http server"
;;
'start')
/websphere/ica/bin/apachetcl -k start
;;
'stop')
/websphere/ica/bin/apachetcl -k stop
;;
*)
echo "usage: $0 {start|stop}"
;;
esac
exit

#
Learning ...
Pete Randall
Outstanding Contributor

Re: startup script

It looks fine. The only question I would ask is do you need any variables set in order to start apache?

If so, you would want to add something like this after the 'start') clause:

if [ -f /etc/rc.config.d/apache ] ; then
. /etc/rc.config.d/apache
else
echo "ERROR: /etc/rc.config.d/apache defaults file MISSING"
fi


Pete


Pete
Dave La Mar
Honored Contributor

Re: startup script

Navin -
Attached is an old doc that still works for what you are attempting. Note that it also supplies the technique used to test the process without actually shutting down or starting up.

Regards,

-dl
"I'm not dumb. I just have a command of thoroughly useless information."