1752808 Members
6015 Online
108789 Solutions
New Discussion юеВ

Re: Load script in Boot

 
SOLVED
Go to solution
Victor Salvador
Occasional Contributor

Load script in Boot

I need auto exec a perl script and the apache WEB Server engine, in the boot process.

My server is HP9000 and HP-UX 11.0

thanks.
4 REPLIES 4
Brian M. Fisher
Honored Contributor

Re: Load script in Boot

The simplest way is to create your startup script in the /sbin/rc3.d directory with the name SXXXprogram-name
where XXX is the order to start lowest first

For the shutdown script, create it in the /sbin/rc2.d directory named KYYYprogram-name
where YYY is the order to stop lowest first.

Brian
<*(((>< er
Perception IS Reality
Alan Riggs
Honored Contributor
Solution

Re: Load script in Boot

The recommended way is to:

1) Copy the file /sbin/init.d/template to the script name you wish.
2) Edit that script, adding the appropriate code in the start and stop sections.
3) Create a resource file in /etc/rc.config.d that sets an environmental variable to 0 or 1. Use 1 to start the script automatically. The name of this environmental variable should match the name you supply for "CONTROL_VARIABLE" in the /sbin/init.d/script.
4) Finally, add soft links in the /sbin/rcX.d directories to control when in teh start sequence you wish the script to be activated.
ex: To start the script at run level 3 issue:
ln -s /sbin/init.d/script /sbin/rc3.d/S800script
ln -s /sbin/init.d/script /sbin/rc2.d/K200script

By convention, the numbers should add up to 1000. This ensures that processes are stopped in the inverse order of when they are started.
Andreas Voss
Honored Contributor

Re: Load script in Boot

Hi,

i give you a apache start/stop script at the attachment (put it in /sbin/init.d/apache).

Greetings

Andrew

Re: Load script in Boot

I had also problems to start a http server (not apache) during boot. Also the game hovercraft does not start its server during boot.

What helps was a script in /sbin/rc2.d like follows:

----

#!/sbin/sh
#

PATH=/usr/sbin:/usr/bin:/sbin:/opt/thttpd/sbin
export PATH


echo 'cd /ansys' > /usr/local/bin/start_http
echo '/opt/thttpd/sbin/thttpd -r -d /ansys -u www &' >> /usr/local/bin/start_http

/sbin/chmod 755 /usr/local/bin/start_http

/usr/bin/at -f /usr/local/bin/start_http now + 2 minutes

echo "Starting thttpd"

exit 0

------
Note that the server is started 2 minutes after booting by cron.