Operating System - HP-UX
1830485 Members
2376 Online
110005 Solutions
New Discussion

Registering to startup application on boot or reboot

 
darren_lee
Frequent Advisor

Registering to startup application on boot or reboot

Hi

Is there a way to register for an application to startup upon boot or reboot?

For solaris, it would be registering it at /etc/rc0.d and /etc/rc3.d.

Is there something similar in HP-UX?

thanks
13 REPLIES 13
James R. Ferguson
Acclaimed Contributor

Re: Registering to startup application on boot or reboot

Hi Darren:

Yes, the 'rc' paradigm applies to HP-UX.

This whitepaper describes everything you need to follow and do. Althouth it first appeared for HP-UX 10.0 it is applicable to all current releases.

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

You can also consult the manpages for 'rc(1M)':

http://docs.hp.com/en/B2355-60105/rc.1M.html

Regards!

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

Re: Registering to startup application on boot or reboot

HP-UX has exactly the same convention with a few wrinkles.

Wrinkle 1) The master scripts are installed in /sbin/init.d. The symbolic links then link from /sbin/rcN.d to the "real" file in /sbin/init.d.

Wrinkle 2) Rather than having the normal "start" and "stop" command line arguments. HP-UX augments them with "start_msg" and "stop_msg".

Wrinkle 3) By convention, environment variables needed by your scripts are sourced from /etc/rc.config.d.

If you will look in /sbin/init.d there is a template script that you can copy and adapt to your needs.
If it ain't broke, I can fix that.
darren_lee
Frequent Advisor

Re: Registering to startup application on boot or reboot

Hi Guys

Thanks for the info. I will try it out and feedback on the results.

Have modified the template and linked it to rc0.d and rc3.d.

cheers
Matti_Kurkela
Honored Contributor

Re: Registering to startup application on boot or reboot

Adding to Clay's answer...

Wrinkle 4) Unlike some other unixes and unix-like systems, when HP-UX moves from one runlevel to another, it will also execute the start/stop scripts for the intervening runlevels.

In other words, when going from runlevel 3 to runlevel 0, the "stop" scripts associated with runlevels 2 and 1 are executed _in addition to_ anything defined specifically for runlevel 0. When going from single-user mode to runlevel 3, the "start" scripts of runlevel 2 are executed too.

So the correct place for "start" link is /sbin/rc3.d, just like /etc/rc3.d in most other unixes, but the "stop" link might be different. The normal place for it would be /sbin/rc2.d.

If you put it to /sbin/rc0.d, the application will be stopped _very_ late in the shutdown sequence: when the scripts in HP-UX /sbin/rc0.d are executed, some rather basic things like NFS and even syslogd have already been shut down. If your application uses these services, it may be unable to shutdown cleanly.

A side effect of putting the application stop link in /sbin/rc2.d is that the application will be stopped whenever you go to the single user mode. Normally this is what you want: if you need the single-user mode, you will be doing some major maintenance and want the system to be as clean as possible.

MK
MK
darren_lee
Frequent Advisor

Re: Registering to startup application on boot or reboot

Thanks

Actually what i need is to have a auto start/stop for vnc services upon booting and shutting down of server.

so, the best place to put is in rc2.d and rc3.d?

cheers
darren_lee
Frequent Advisor

Re: Registering to startup application on boot or reboot

hi

i have tried, but when i perform a reboot, it does not start.

what i have done is modify the template and create a link to it at rc0.d,rc2.d,rc3.d.

the vnc services still did not start.

any idea what went wrong?

cheers

darren_lee
Frequent Advisor

Re: Registering to startup application on boot or reboot

Attached is the modifed template.

Bill Hassell
Honored Contributor

Re: Registering to startup application on boot or reboot

> what i have done is modify the template and create a link to it at rc0.d,rc2.d,rc3.d.

No, you provide a start link only at the level you want it to start and the name of the link is the alphabetic sequence where you want it to start after other services. The stop link would typically be one level lower than the start script and would be named in sequence to run in front of other system shutdown services. The output from all start/stop scripts is found in /etc/rc.log and /etc/rc.log.old where you can see any error messages.

Always test your script manually:

/sbin/init.d/myscript stop
/sbin/init.d/myscript start


Bill Hassell, sysadmin
Yogeeraj_1
Honored Contributor

Re: Registering to startup application on boot or reboot

hi Darren,

old but gold.

The attached document should clarify all your doubts.

HP-UX 10.X Startup and Configuration

hope this helps!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Bill Hassell
Honored Contributor

Re: Registering to startup application on boot or reboot

And just a note about the VNC server -- does it automatically disconnect from the parent and run in the background like a daemon? If not, you must start it in the background with & as in:

su - oracle -c "/usr/local/vnc/vncserver :13" &


Bill Hassell, sysadmin
darren_lee
Frequent Advisor

Re: Registering to startup application on boot or reboot

thanks to all. i am able to start stop the vnc services now at bootup/shutdown.

However, when it starts up, the screen will load normally and show the desktop. After a while, the whole screen will turn grey and i am unable to do anything.

This can be rectified by stopping and restarting the vnc server again manually but i think this should not be the case.

any suggestions??
darren_lee
Frequent Advisor

Re: Registering to startup application on boot or reboot

Hi All

The screen is still grey after i reboot and i am not sure why this is happening.

When i manually run the vnc script (which is used at reboot), it will work fine. But i need it to work at reboot or cold start.

Please kindly advise..

Thanks...
darren_lee
Frequent Advisor

Re: Registering to startup application on boot or reboot

Thank you to all that have helped.

Have managed to solve the problem.