Operating System - HP-UX
1846995 Members
3635 Online
110257 Solutions
New Discussion

Re: scripts starting at boot time

 
Allan Pincus_1
New Member

scripts starting at boot time

I have created a script that starts an http daemon. I set a shell variable HTTP=1 in my rc.config.d directory, I have my script to launch in the /sbin/init.d directory, I set up the start up link in /sbin/rc3.d and the kill link in /sbin/rc2.d.

When I run the script manually, it runs fine. I can stop and start my daemon at will, running the process in the background (with &).

But when I reboot, it does not start. Yes, I get the "start_mesg" and "stop_mesg" but my log file doesn't update, and when I grep out the process (httpd) it's not started.

I'm going crazy! Any one have any ideas?????

- Allan
9 REPLIES 9
Philip Chan_1
Respected Contributor

Re: scripts starting at boot time

Is your startup pointer under /sbin/rc3.d starts with the "S" character looking like "/sbin/rc3.d/S020apache" for example?

Also, check /etc/rc.log to look for any output messages for your http startup script. You can locate the relating lines within the file quicker by searching against your startup script name (S020apache for my example above).

Rgds,
Philip
Allan Pincus_1
New Member

Re: scripts starting at boot time

Yup, capital "S" in the start up, and no obvious error in the rc.log file (I already checked).

Is there some special way needed to launch my script other than with "&".

Sridhar Bhaskarla
Honored Contributor

Re: scripts starting at boot time

Hi Allan,

As you are getting the start and stop messages, I believe that the script is getting executed properly during the startup. I would suggest you to keep the debug line "set -x" at the beginning of the script and observe the output. Your console may clobber a bit but it will help you troubleshoot the problem.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Sajid_1
Honored Contributor

Re: scripts starting at boot time

Add debug options (simple echo commands to some output files) in the startup/shutdown scripts. Check the file permissions. Also check the shell used by the scripts.
learn unix ..
Frank Slootweg
Honored Contributor

Re: scripts starting at boot time

Put this at the beginning of your script, reboot and check /etc/rc.log:

exec 2>&1
set -x

The "exec 2>&1" will cause all standard error output to go to where standard outpui is going, which is to /etc.rc.log.

The "set -x" will log each executed command, so that when you see an err in (/etc/rc.log) you will know which command gave that error.

Philip Chan_1
Respected Contributor

Re: scripts starting at boot time

Allan,

Can you actually see the following lines for your process in /etc/rc.log?

Starting
Output from "/sbin/rc3.d/Sxx"

... ba-ba-ba ...


If these lines weren't there that mean they weren't even executed.

What about run level, was it set to 3 in /etc/inittab?
Jim Butler
Valued Contributor

Re: scripts starting at boot time

Check the shell you are running the script in

i.e. top line may need to be added or altered to be

#!/sbin/sh or whatever shell you are running in (do an echo $SHELL) of the user that successfully runs the script, and then set that within the script.

good luck
Man The Bilge Pumps!
Allan Pincus
Frequent Advisor

Re: scripts starting at boot time

All,

I got it!

Problem was this:

1. I needed to use "nohup" to launch my script.

2. I had to add /usr/bin to the PATH variable inside the script. This path was not picked up yet where I launched the script, so the shell couldn't find "nohup". (I put my script right before CDE started in rc3.d. So I was surprised by this.)

Thanks for all your help! It gave me clues. I hope this helps someone else out there.

- Allan
Frank Slootweg
Honored Contributor

Re: scripts starting at boot time

Do you have/use two ITRC accounts with the same user name ("Allan Pincus") ?

Your 02:27 AM GMT response correctly says "[ N/A: Question Author ]", but your 13:01 PM GMT response says "[ unassigned ]" which implies that you are not the Question Author, but obviously you are.

One account is of ("ITRC member since:") August 21, 2002, the other is of August 05, 2002.

I advise to delete one of these accounts because two accounts with the same user name is confusing.