1847104 Members
5124 Online
110263 Solutions
New Discussion

Re: start up scripts!!

 
SOLVED
Go to solution
Sprint Unix Team
Frequent Advisor

start up scripts!!

HOw do i include my application startup script to start automatically when the system reboots.
I believe this has to be include in the startup script
8 REPLIES 8
Stefan Farrelly
Honored Contributor

Re: start up scripts!!


You need to create a script in /sbin/init.d which actually does the startup and shutdown in one script (depending on wether the start or stop argument is passed to it). Then create a link in /sbin/rcX.d for the startup (usually runlevel 3 for apps) and one in /sbin/rcX.d for shutdown (usually runlevel 2). You should also create a variable script in /etc/rc.config.d which has a variable which decides if your app will start or not.

Theres plenty of examples to use as a base for your application startup script. A simple example is (on 11.0);

/sbin/init.d/pwgr

Take a look at it. It sources a file called /etc/rc.config.d/pwgr which has a vairiable which declares wether to start pwgr or not. There is a stop and start section, you can edit this for your own application, and there are 2 symbolic links in /sbin/rc2.d to start it up when the system goes to runlevel 2, but no shutdown link (which would be something like K [for kill] XXX.)
Im from Palmerston North, New Zealand, but somehow ended up in London...
Sachin Patel
Honored Contributor

Re: start up scripts!!

Hi
1. cd /sbin/init.d
2. cp template yourscritpname
3. vi yourscript
I edit start_msg statment
II edit stop_msg statment
III edit start statment
a. change control_variable to yourvariable
b. add command to start you application

IV edit stop statment
a. mostly same as start statment

V vi /etc/rc.config.d/yourscript
add line "yourvariable=1"
VI ln -s /sbin/init.d/yourscript /sbin/rc3.d/S800yourscript (to start in runlevel 3)
VII ln -s /sbin/init.d/yourscript /sbin/rc2.d/K800yourscript (to kill your application in runlevel 2)

I hope this helps.

Sachin
Is photography a hobby or another way to spend $
Denver Osborn
Honored Contributor

Re: start up scripts!!

Start with making a copy of /sbin/init.d/template to /sbin/init.d/my_script and modify as needed.

I could go into detail, but would recommend looking at ITRC document id UNX1000486.

Hope this helps
-denver
Jim Turner
HPE Pro

Re: start up scripts!!

Another good reference is /usr/share/doc/start_up.txt. I have attached a copy for your convenience.
Sprint Unix Team
Frequent Advisor

Re: start up scripts!!

Thanks a lot. I would like to know the significance of S800, S200, S945, S941 etc in /sbin/rc3.d directory.

What does 800, 200, 945 signify?? Does these nos dependent on the hardware or I simply use S800 to startup??
Mark Vollmers
Esteemed Contributor
Solution

Re: start up scripts!!

THe numbers for the run levels are defined in the "HPUX startup and configuration" manual(maybe not the right word, but it has the info. These are from 10.20, but they are probably close. For run level 2, 0xx is reserved for temporary links, 1xx is software installation/config, 2xx is essential local daemons/services, 3xx is networking startup, 4xx is NFX/NIS, 5xx-6xx is services built on top of network services, 7xx-8xx are other local daemons/services, and 9xx is reserved for future expansion. 900 is generic run-level 2. For run level 3, 0xx is temp links, 1xx is NFS exports, 2xx-8xx are not used, and 9xx is future expansion. We have software that is up at S999. I think you can pick any number you want up there (we have S999 since that is the last thing to start before the CDE loads). Hope this helps.

Mark
"We apologize for the inconvience" -God's last message to all creation, from Douglas Adams "So Long and Thanks for all the Fish"
James R. Ferguson
Acclaimed Contributor

Re: start up scripts!!

Hi:

The 3-digit number is the sequence in which startup (or shutdown) scripts are exeucted (low-to-high). Startup scripts begin with an "S"; kill scripts begin with a "K". Startup scripts are exeucted when transiting from run-level N to N+1. Kill scripts execute when moving from level N to N-1.

A general rule is that the sum of the startup script's sequenece (3-digits) and the kill script's sequence equals 1000. Thus, a startup script coded at "S900" would have its kill counterpart specified as "K100".

The PDF-format white paper (below) is worth reading for all the details of this paradigm:

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

...JRF...
Rob Smith
Respected Contributor

Re: start up scripts!!

Hi, look in the /usr/share/doc directory for a file called start_up.txt. This will tell you everything you need to know.

Points assigned to only 2 of 60 responses is really, really not good. Start assigning points to the people that take their time to help you or they will not want to help you anymore. Hope this helps.

Rob
Learn the rules so you can break them properly.