Operating System - HP-UX
1849379 Members
5902 Online
104044 Solutions
New Discussion

Re: start up script in rc3.d

 
Marta_12
Frequent Advisor

start up script in rc3.d

Hello,
I have a script in boot level rc3.d which doesn't execute the command into in.
I have included "set -x" trace in the script and I can see the ouput in rc.log and everything seems OK.
I cannot see any errors in rc.log related to this script and the Paths are defined correctly.
The only problem is the command (PatrolAgent) is not executed for some weird reason.
I can also run the script manually as root.
Any ideas? Anything to check?

P.S. I haven't included anything in /etc/rc.config.d. Is it mandatory?

Marta
6 REPLIES 6
Tim Nelson
Honored Contributor

Re: start up script in rc3.d

If you are using the standard template in /sbin/init.d/ then check on your control variable in /etc/rc.config.d/my_app

The template uses a user defined control variable either set to 1 for yes or other_value for no.

A. Clay Stephenson
Acclaimed Contributor

Re: start up script in rc3.d

It's not required that you have a configuration file associated with your rc'ed script BUT it is highly encouraged as at the least it will (if your code branches properly) allow an easy way to enable/disable your script. Moreover, in HP-UX this is the standard location for setting any needed environment variables for your rc'ed scripts. I strongly suspect that your fndamental problem (since it works from an interactive shell) is that you are missing key environment variables (PATH?) because of the sparse rc environment. It is also possible that you have problems because the stdin and/or stdout of your process when run by rc is not a terminal device.
If it ain't broke, I can fix that.
Marta_12
Frequent Advisor

Re: start up script in rc3.d

Thank you guys for your answers.

I'm not using a template based script, it is a custom one.
The PATH environment variable is exported within the script, and it's not the problem, since the trace shows the entire path to the exec command.
The stdout could be an issue, since my command generates an output. To avoid this I have added
> /dev/null 2&>1. Is it correct?


Marta
Ernesto Cappello
Trusted Contributor

Re: start up script in rc3.d

Hi Marta
the standard option

"filename.sh" >/dev/null 2>&1

to redirect is right.
Best regards.
Ernesto
A. Clay Stephenson
Acclaimed Contributor

Re: start up script in rc3.d

This syntax:
> /dev/null 2&>1
should be:
> /dev/null 2>&1

but note that there may be many more environment variables required than simply PATH.
If it ain't broke, I can fix that.
Marta_12
Frequent Advisor

Re: start up script in rc3.d

Thanks everybody. I'll doublecheck if the environment is being exported within the script.
Anyway, the most weird thing is that in some systems the script works OK at system boot but it does not in other identical systems.

Thanks and regards.
Marta