HP-UX System Administrator's Guide: Routine Management Tasks

1. Decide at what run level(s) you want the subsystem to start and stop.
Typically, subsystems get stopped at one run level lower than the one they were
started in, so a subsystem started at run level 3 will be stopped at run level 2. You
will probably want to start your subsystem at level 1, 2 or 3.
Generally, these run levels perform the following functions:
Run level 1: minimal system configuration
Run level 2: multi-user services, except NFS server
Run level 3: NFS server (to share local file systems)
To see exactly what is being started on your system at each run level, look at
/sbin/rcn.d/S*, where n is the run level.
Unless your subsystem depends on NFS-export services such as rpc.mountd and
nfsd, run level 2 is a good place to start it.
Run level 2 is a safe, as well as usually a logical, choice because it has a placeholder
which HP guarantees will not be overwritten by future releases of HP or third-party
software; there is no such placeholder, and hence no such guarantee, at the other
run levels.
2. Write a script to start and stop the subsystem, and an accompanying configuration
script to tell the boot process whether or not this script should be run.
Use the template /sbin/init.d/template; see the example below.
3. Create symbolic links that will cause your script to be run at the right place in the
boot and shutdown sequences.
See the example below.
4. Reboot the system to make sure everything works.
On a busy system, this may be inconvenient, but beware of testing on a
configuration other than the one on which your subsystem will actually run; any
differences in start-up/shutdown configuration between the test system and the
production system may invalidate the test.
Example:
This example shows one way to automate the start-up of a server daemon, called
web_productname_daemon:
Customizing Start-up and Shutdown 81