1847342 Members
2141 Online
110264 Solutions
New Discussion

start a script at boot

 
iranzo
Frequent Advisor

start a script at boot

How starting a script without start or stop
argument when an hpux boot .

Thanks
Bonjour
9 REPLIES 9
Alexander M. Ermes
Honored Contributor

Re: start a script at boot

Hi there.
Check the scripts in /sbin/rc2.d or /sbin/rc3.d
Look at these scripts. Setup your script the same way. Place it in /sbin/rc3.d and it should work.
Rgds
Alexander M. Ermes
.. and all these memories are going to vanish like tears in the rain! final words from Rutger Hauer in "Blade Runner"
Robin Wakefield
Honored Contributor

Re: start a script at boot

Hi,

The /sbin/rc script *expects* you to use the start/stop arguments. Have you any more details/reasons for this request?

Rgds, Robin.
Wim Rombauts
Honored Contributor

Re: start a script at boot

Just make your script, as if it is a normal startup/shutdown script. The start and stop parameters will be ignored if you don't use them.

If those parameters are in the way, make a small start/stop script in /sbin/init.d that sources or executes your script without parameters if it is started with the "start" parameter.

Steven Sim Kok Leong
Honored Contributor

Re: start a script at boot

Hi,

The stub procedure goes like this:

=============================
#!/sbin/sh

case $1 in
start) # enter startup command here ;;
stop) # enter shutdown command here, optional ;;
start_msg) # enter startup message here, optional ;;
stop_msg) # enter shutdown message here, optional ;;
esac
=============================

Hope this helps. Regards.

Steven Sim Kok Leong
Brainbench MVP for Unix Admin
http://www.brainbench.com
Ian Dennison_1
Honored Contributor

Re: start a script at boot

Create a dummy script in the /sbin/init.d that has the standard 'start/stop' options, which then calls the relevant script with the appropriate options.

eg. sap_ctrl script (for starting sap) calls the 'start_sap' command as p01adm in the 'start' conditional.

The script does have to work within the guidelines and standards set by HP-UX.

Share and Enjoy! Ian
Building a dumber user
Frederic Sevestre
Honored Contributor

Re: start a script at boot

Hi,
Usualy to start process on boot :
Create your script on /sbin/init.d
Create a link from this scrip to /sbin/rcx.d (where x indicate the start level) called SXXXyourscript.
Fr??d??ric
Crime doesn't pay...does that mean that my job is a crime ?
Praveen Bezawada
Respected Contributor

Re: start a script at boot

Hi
If you just want to run a script at startup and shutdown you can place your script in /sbin/init.d, create soft links in /sbin/rc3.d for startup and soft link in /sbin/rc2.d for shutdown and the configuration file, if your want to run it occasionally in /etc/rc.config.d
Let it do what you want to do ignoring the start and stop argument. But I think you need to handle the startmsg and stopmsg arguments.

...BPK...
Darrell Allen
Honored Contributor

Re: start a script at boot

Hi,

As others say, the appropriate method for starting processes at boot time is the RC scripts. As long as your script's name begins with a capital S the script will be executed by /sbin/rc when it executes scripts for that run level. You don't have to use the case statement with start, stop, etc but it is highly recommended.

As an alternative, you could use /etc/inittab. This is not the generally accepted method and I suggest you avoid it. Mess up inittab and you've got trouble.

My advice is to stick with the RC scripts. It is the standard, there are templates (just use any system supplied rc script as a guide), and logging is provided (/etc/rc.log).

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Sanjay_6
Honored Contributor

Re: start a script at boot

Hi Malosse,

Try this pdf,

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

Hope this helps.

Regds