Operating System - HP-UX
1832989 Members
3751 Online
110048 Solutions
New Discussion

Re: start application when the machine start

 
malki_3
Frequent Advisor

start application when the machine start

I hav e an application that I want to launch when the machine reboot..
How can I do
Thinks for your help
7 REPLIES 7
G. Vrijhoeven
Honored Contributor

Re: start application when the machine start

melvyn burnard
Honored Contributor

Re: start application when the machine start

try reading /usr/share/doc/start_up.txt on your system. This explains it all.
My house is the bank's, my money the wife's, But my opinions belong to me, not HP!
malki_3
Frequent Advisor

Re: start application when the machine start

But I do it forever so this application must be running on each time the server reboot
James R. Ferguson
Acclaimed Contributor

Re: start application when the machine start

Hi:

If you haven't, read either version of the document below. I???ll summarize the key points here.

/usr/share/doc/start_up.txt

http://docs.hp.com/hpux/onlinedocs/os/startup.html

The file /sbin/init.d/template is a good starting place for making your own start/stop scripts.

The /sbin/init.d directory contains all scripts used to startup and shutdown various subsystems.

Each script under /sbin/init.d should perform BOTH the startup and shutdown functions. In order to control the functionality within the script, each must also support standard arguments and exit codes. Scripts must be written for the POSIX shell. A template script may be found in /sbin/init.d/template.

There is no reason why the startup and shutdown script cannot start/kill multiple, but related processes. Remember to choose the appropriate rc.d directory -- one (1) is for core services; two (2) is for multiuser run-state; three (3) is for networked, multi-user; and four (4) is for graphical interfaces. Depending on the processes you are starting, or stopping, you want to make sure prerequisite services exist.

Each script in /sbin/init.d performs BOTH the startup and shutdown functions, and each will have two links pointing towards the script from /sbin/rc*.d: one for the start action and one for the stop action.

Start scripts begin with "S"; Kill (stop) scripts begin with "K". The order of execution for kill scripts is the reverse of the startup ones.

if a start script is placed in directory '/sbin/rc{X}.d' then its corresponding kill script is put in directory '/sbin/rc{X-1}.d'

A general rule-of-thumb is that the sequence number of the start script plus the sequence number of the kill script should add to 1000.

Subsystems should be killed in the opposite order they were started. This implies that kill scripts will generally not have the same numbers as their start script counterparts. If two subsystems must be started in a given order due to dependencies (e.g., S200sys1 followed by S300uses_sys1), the counterparts to these scripts must be numbered so that the subsystems are stopped in the opposite order in which they were started (e.g., K700uses_sys1 followed by K800sys1). The '1000' rule leads to this behavior.

Regards!

...JRF...
Sachin Patel
Honored Contributor

Re: start application when the machine start

Hi

file /sbin/init.d/template is a good starting place for making your own start/stop scripts.

Each script under /sbin/init.d does both the startup and shutdow. And once you write your script and test it out you create two links one for startup and one for shutdown.

for eg: you create a script called "xyz" make it an executable and set the right permissions and test it
you want this to come up in run level 3. create a link

ln -s /sbin/init.d/xyz /sbin/rc3.d/S992xyz
ln -s /sbin/init.d/xyz /sbin/rc2.d/K992xyz

This ensures that your scripts does a start in run level 3 and a stop in run level 2

How to test it.
Run
#/sbin/rc3.d/S992xyz start

If it don't work and if you want to debug then add
set -x
on top of /sbin/init.d/xyz script.
Run it again and it will run it in debug mode.

Sachin
Is photography a hobby or another way to spend $
Jon Mattatall
Esteemed Contributor

Re: start application when the machine start

This has been heavily covered here, but...

Quick & Dirty -

Put your start | stop script for your application in /sbin/init.d/ - check the scripts there for examples if you don't have a script.

Create links in /sbin/rc#.d/ as so...

ln -s /sbin/init.d/appscript /sbin/rc2.d/K123app

ln -s /sbin/init.d/appscript /sbin/rc3.d/S877app

This will run the script with the "stop" (K) parameter when the box goes down to run-level 2, and with the "start" (S) parameter when it enters run-level 3.

The K### and S### numbers are usually set to add up to 1000 - That's convention, not required.

Any configuration files tend to go in /etc/rc.config.d/

At any rate, a search of the forums will give you a TON of info.

HTH

Jon
A little knowledge is dangerous - none is absolutely terrifying!!!
Sukant Naik
Trusted Contributor

Re: start application when the machine start

Hi Malki,

Copy your startup shell script to the /sbin/init.d directory. Then create links to the /sbin/rc3.d directory beginning with the letter 'K' and a serial number alongwith your script name and a 'S' with a serial number alongwith your script name.

Please read man rc as the sequence of startup and shutdown matters.

Thats all.

-Sukant
Who dares he wins