Operating System - HP-UX
1820643 Members
2030 Online
109626 Solutions
New Discussion юеВ

Starting and Stopping a Program with a Startup/Shutdown Script

 
Andrew Kaplan
Super Advisor

Starting and Stopping a Program with a Startup/Shutdown Script

Hi there,

I have a third-party client program, Nagios NRPE client, running as a standalone daemon on an HP-UX 10.20 machine. I am trying to get it to run automatically on bootup and do an automatic shutdown.

The easiest solution has been for me to create a single-line startup script which invokes the client. The full command is

/opt/nrpe/bin/nrpe -c /opt/nrpe/nrpe.cfg --daemon

The client is started via an S script in the /sbin/rc2.d directory. There are two problems with this approach.
First, when the system does boot up, and lists the services as being started, the client is started but the listing for the client shows a blank space while the other daemons names are mentioned.
Second, when shutting down the workstation, there is no way to know if the nrpe daemon is being successfully turned off.

The altenative option is to clone an existing startup script and modify that to suit the nrpe client. I have done that and manually ran the script to test it. Although the script can start the nrpe client, it is unable to stop it. I have included the script in this message.

The question is, what is the correct syntax for stopping the nrpe client via the startup script?
A Journey In The Quest Of Knowledge
3 REPLIES 3
Pete Randall
Outstanding Contributor

Re: Starting and Stopping a Program with a Startup/Shutdown Script

It would be stopped by a kill, or K, script in /sbin/rc1.d (the next lower level).


Pete

Pete
A. Clay Stephenson
Acclaimed Contributor

Re: Starting and Stopping a Program with a Startup/Shutdown Script

Eventhough you are able to start the daemon manully that may not be enough to start/stop using rc. Make sure all PATHS and any other needed env vars are set and exported in your scripts - remember .profile is not sourced.

After you have installed your script in /sbin/init.d/ e.g/ /sbin/init.d/nrpe and made it executable then you need to symbolically link it to entries in the rcN.d directories. The script is manually invoked as /sbin/init.d/nrpe start (or stop).

Let's assume that you want to start at run level 3. Generally, you want to stop it at one lower run-level, i.e. 2.

You would link like this:

ln -s /sbin/init.d/nrpe /sbin/rc3.d/S900nrpe

and

ln -s /sbin/init.d/nrpe /sbin/rc.d/K100nrpe.

By convention the "S" numbers plus the "K" numbers = 1000. That tends toi order the sequence correctly.
If it ain't broke, I can fix that.
Steven E. Protter
Exalted Contributor

Re: Starting and Stopping a Program with a Startup/Shutdown Script

Any environment variable can mess things up. Though counter to logic, some startups require a TERM variable. Probably not this one.

You can use /sbin/init.d/template as a template for that script.

Just make a copy, don't mess with the original.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com