1837963 Members
2549 Online
110124 Solutions
New Discussion

Boot Alert Script

 
SOLVED
Go to solution
Fred Martin_1
Valued Contributor

Boot Alert Script

I wish to be alerted via an email-page whenever my HP-UX 10.20 system Boots.

I already have written a script that works fine, I only need to insert it into the rc process someplace.

It's not a service to start or stop, just a simple execute. Requires /usr/bin and needs sendmail running, so the script must run after mounts and after sendmail starts.

What's the proper place to put the script?

Thanks,
Fred
fmartin@applicatorssales.com
11 REPLIES 11
Brian M. Fisher
Honored Contributor

Re: Boot Alert Script

A good place to put the script is in /sbin/rc3.d/SXXXscriptname where XXX is larger than the other numbers in the directory. This will run your script after everything else has started.

Brian
<*(((>< er
Perception IS Reality
Albert E. Whale, CISSP
Honored Contributor

Re: Boot Alert Script

Fred,

Why not add it as the entry in the inittab? I would include it as a 'once' feature for the run-level 3 (or whatever your default level of operation is).

That way, whenever your server comes back to this level, you'll be notified.

Hope that helps.
Sr. Systems Consultant @ ABS Computer Technology, Inc. http://www.abs-comptech.com/aewhale.html & http://www.ancegroup.com
Kofi ARTHIABAH
Honored Contributor

Re: Boot Alert Script

Since the rc scripts are executed in Ascending order, you will have to set up your script to have a number that is greater than the Start number for sendmail -eg.

if your sendmail startscript is /sbin/rc2.d/S540sendmail you will have to configure your bootalert script to be say /sbin/rc2.d/S550bootalert.

Good luck.
nothing wrong with me that a few lines of code cannot fix!
Fred Martin_1
Valued Contributor

Re: Boot Alert Script

Brian, a bit confused about rc2.d and rc3.d - in another thread you said that rc3.d scripts are for startup, rc2.d scripts are for shutdown.

If that's true, wouldn't my script be placed in rc2.d?

Thanks,
Fred
fmartin@applicatorssales.com
Patrick Wessel
Honored Contributor
Solution

Re: Boot Alert Script

Fred,

You'll find the "System Startup White Paper" attached to this message. It describes the use of the start/kill Scripts in /sbin. Maybe it gives you a closer look when the scripts are executed.
There is no good troubleshooting with bad data
Brian M. Fisher
Honored Contributor

Re: Boot Alert Script

Fred,

I was under the impression you wanted the message sent after the reboot was completed, instead of as the system was going down. If you want it to execute as the system is going down, put the script in /sbin/rc2.d/KXXXscriptname where XXX is a low number that gets executed as soon as the system shutdown starts. Keep in mind these scripts are NOT executed if the reboot command is issued.

Brian
<*(((>< er
Perception IS Reality
Fred Martin_1
Valued Contributor

Re: Boot Alert Script

Brian, I did want it exececuted as the system starts up, so I'll be aware of any boots caused by catastrophic events like somebody recycling the power on the box without a shutdown, etc.

Thanks much,
Fred
fmartin@applicatorssales.com
Donald Branch
Occasional Contributor

Re: Boot Alert Script

I put mine at the end of the /sbin/rc script so the last thing the system does is sendout the email just added a couple of lines to it. Only danger is if you upgrade your system this script will problably be overwritten.
It' not over until the fat lady sings!
Duane Gorder
Advisor

Re: Boot Alert Script

A key point to keep in mind is that on the way up the system starts the jobs in /sbin/rc*.d that begin with a capital S, and on the way down it executes scripts whose names begin with a capital K. The rc* number corresponds to the run level and the system executes the scripts in all the run levels that it passes until it reaches the target run level. To get to run level three, it executes rc1.d/S*, rc2.d/S*, and rc3.d/S*. Since sendmail is rc2.d/S540sendmail it should either be a higher number in rc2.d, or it should be in rc3.d
Live each season as it passes; breathe the air,
Albert E. Whale, CISSP
Honored Contributor

Re: Boot Alert Script

Fred,

I take it that you do not like the idea of installing the script in the inittab? It's Very convenient, and you do not need to code the acceptance of the arg $1 being either a start or a stop command.

HTH!
Sr. Systems Consultant @ ABS Computer Technology, Inc. http://www.abs-comptech.com/aewhale.html & http://www.ancegroup.com
Fred Martin_1
Valued Contributor

Re: Boot Alert Script

Albert
It's more an issue of comfort than disliking it - I don't typically mess with system files like inittab unless really necessary; also I assumed that inittab was better suited to stuff that needs to re-spawn, etc. but thanks for the idea.
Fred
fmartin@applicatorssales.com