Operating System - HP-UX
1833772 Members
2284 Online
110063 Solutions
New Discussion

customized startup scripts in /sbin/init.d

 
SOLVED
Go to solution
Gary Yu
Super Advisor

customized startup scripts in /sbin/init.d

Hi all,

I'm trying to add a customized startup script in the /sbin/init.d directory to start our application(broadvision) automatically at boot time. I'm creating the start link at rc3.d and kill link at rc2.d

I run the script in command line, it works fine, but the problem is, when it invoked at bootup time, some background process cannot be started, . my question is, is there any difference between runing a script from init at boot time and from normal shell command line?

thanks,
Gary
8 REPLIES 8
Rich Wright
Trusted Contributor

Re: customized startup scripts in /sbin/init.d

In the /sbin/init.d/<script> , Be sure to either set the PATH variable or use fully qualified path names for all commands.
James R. Ferguson
Acclaimed Contributor

Re: customized startup scripts in /sbin/init.d

Hi Gary:

Yes, the environmental variables are probably quite different. Remember, any variables sourced and exported by your profile during login are absent. Make sure that your 'rc' script has at least a PATH variable set and that you declare any other environment you need.

Regards!

...JRF...
Leif Halvarsson_2
Honored Contributor

Re: customized startup scripts in /sbin/init.d

Hi
One difference is enviroment variables such as PATH is set in your login session but not automatic at booting. Check your script which variables needs to be set (and dont forget to export).
Martin Johnson
Honored Contributor

Re: customized startup scripts in /sbin/init.d

Make sure your script defines the necessary PATH and environment variables. The script should be as self-contained as possible.

HTH
Marty
PIYUSH D. PATEL
Honored Contributor

Re: customized startup scripts in /sbin/init.d

Hi,

Go thro this link.....

http://docs.hp.com/hpux/onlinedocs/os/startup.pdf

Have you created something in the /etc/rc.config.d also ???

Also post your scripts and check whether the PATH is correct. Put the full path of the command like /usr/bin/ls instead of just ls

Piyush

Piyush
Jeff Schussele
Honored Contributor

Re: customized startup scripts in /sbin/init.d

Hi Gary,

As Rich has noted you have a very sparse environment because there's no login - you must explicilty setup any env parms OR use su - username - c "command string" commands.

Also exactly *how* you name the links in rc3.d/rc2.d can play a part. If you name them LOWER than another script that this script is dependent on - you've got a problem. So when in doubt, name it high enough so that you know everything else you might need is already running.

And you probably know but the Sxxxfilename & Kxxxfilename numbers in rc3.d/rc2.d should equal 1000. NOT required, but good practice.

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Gary Yu
Super Advisor

Re: customized startup scripts in /sbin/init.d

thanks guys for the quick response. I'm using su - user_name -c "command" in the start scripts in /sbin/init.d, that should bring all environment variables in. from the output logged in /etc/rc.log, it seemed all process are started(there's one line output for each process started) but when I logged in and checkeed, some of them doesn't show up ...

thanks,
Gary
Frank Slootweg
Honored Contributor
Solution

Re: customized startup scripts in /sbin/init.d

> from the output logged in /etc/rc.log, it
> seemed all process are started(there's one
> line output for each process started) but
> when I logged in and checkeed, some of them
> doesn't show up ...

If the processes are not designed as daemons, you have to start them with nohup(1) *and* allow for some time after each nohup command for nohup to do its work, i.e.

nohup real_command &
sleep 1

The sleep is really a hack, because you should really *check* if real_command has actually started.

You will probably also need to redirect standard in or/and standard out or/and standard error.
Gary