Operating System - HP-UX
1834794 Members
2594 Online
110070 Solutions
New Discussion

Re: how to make sartup script

 
SOLVED
Go to solution
siva baskaran
Regular Advisor

how to make sartup script

dears,
i would like add some file at start up what are the steps like this is this file /opt/sw/mygame

now mi need whenever start the server it should it automatically

please give the procedure with example

thanks
siva
5 REPLIES 5
Chan 007
Honored Contributor

Re: how to make sartup script

Hi

Start up when login,

then use

.profile in $HOME

exec /opt/sw/mwgame

This will directly start when as you login.

Chan
MarkSyder
Honored Contributor

Re: how to make sartup script

You need to put the script in /sbin/init.d then put a link to it in either /sbin/rc2.d or rc3.d, depending on whether it is to be loaded in run level 2 or 3. You'll need two links: one starting with an S to start it and the other starting with a K to kill it.

I'm not sure how you choose the number that comes after the S and the K, but someone who does is bound to be along shortly!

Mark Syder (like the drink but spelt different)

The triumph of evil requires only that good men do nothing
Ninad_1
Honored Contributor
Solution

Re: how to make sartup script

Copy the /sbin/init.d/template to /sbin/init.d/mygame
Edit the file and add the commands to start the script under section 'start') in the case switch options in the mygame file where its written
# Execute the commands to start your subsystem
Similarly write the commands to stop the script under stop section after the line
# Execute the commands to stop your subsystem

Now goto /sbin/rc3.d and create a link to the file
ln -s /sbin/init.d/mygame S900mygame
goto /sbin/rc0.d and create a link
ln -s /sbin/init.d/mygame K900mygame.

And you are ready to roll.

Regards,
Ninad
James R. Ferguson
Acclaimed Contributor

Re: how to make sartup script

Hi:

For a complete understanding of how to properly setup startup (and shutdown) processes (which is quite easy), read this short white paper

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

Disregard the fact that the paper is written for HP-UX 10.x -- it applies to all version onward.

As noted, there is a template file that you should modify to setup your own startup/shutdown script: '/sbin/init.d/template'

Regards!

...JRF...
A. Clay Stephenson
Acclaimed Contributor

Re: how to make sartup script

The suggested method to assigning the "numbers" to the "S" and "K" symbolic links is as follows:

1) Using the "tempplate" file in /sbin/init.d/ as a guide, copy this file to a new file, e.g. /sbin/init.d/myscript and modify to fit your needs. The code that should be executed at startup goes in the start) section of the case statement. Similarly, the code that shold be executed at shutdown goes in the stop) section. There are also start_msg) and stop_msg sections that can be used to echo messages.

2) Determine the run-level that you wish to start the script. The start scripts run in lexical order so for example if you wanted your script to start rather late at run-level 3 then you would create a symbolic link like this:
ln -s /sbin/init.d/myscript /sbin/rc3.d/S950myscript/

3) If the script starts in run-level N then it should be stopped at run-level N-1. You should use a 3-digit decimal number so that
the "start" and "stop" numbers add to 1000. In our example, if your start script is "950" then your stop script should be "050". This convention generally orders the start and stop sequence correctly.
ln -s /sbin/init.d/myscript /sbin/init.d/K050myscript
If it ain't broke, I can fix that.