Operating System - HP-UX
1834698 Members
2569 Online
110069 Solutions
New Discussion

Executing Script While System Booting...

 
SOLVED
Go to solution
susee_sundar
Regular Advisor

Executing Script While System Booting...

Hi I want to Execute a Script while Booting or Entering Runlevel 3...& to Kill it in Level 2...

Give me the steps that I need to do...
6 REPLIES 6
Warren_9
Honored Contributor

Re: Executing Script While System Booting...

hi,

1. create a new start and stop script in /sbin/init.d/ and you could use the script /sbin/init.d/template as the template.

2. create a softlink in /sbin/rc3.d
# ln -s /sbin/init.d/[your script] /sbin/rc3.d/S***[your script]

3. create a softlink in /sbin/rc2.d
# ln -s /sbin/init.d/[your script] /sbin/rc2.d/K***[your script]

you may also create a startup configure file in /etc/rc.config.d/

GOOD LUCK!!!

Devesh Pant_1
Esteemed Contributor

Re: Executing Script While System Booting...

Susee Sundar,

you need to create links in the /sbin/rc3.d for the startup execution at runlevel3 and /sbin/rc2.d for the kill execution at runlevel 2

example:
say the scripts are /usr/local/bin/script2start
and
/usr/local/bin/script2stop

make sure it has the standard start/stop format see attachment example

place this startstopscript in the /sbin/init.d directory make sure the execuable permissions are correct

cd to /sbin/rc3.d and create the link
ln -s /sbin/init.d/startstopscript S901startstopscript

this will create a link for the starup

now for the shutdown cd to /sbin/rc2.d and create another link

ln -s /sbin/init.d/startstopscript K99startstopscript

this will create the kill or the stop link
This should do it

thanks
DP
susee_sundar
Regular Advisor

Re: Executing Script While System Booting...

Well DP & Warren..

From Your Guidelines...Here I Created the steps
Suggest Me whether it is Right...

The Script to Start is /sbin/init.d/Start
_Backup
The Script to Stop is /sbin/init.d/Stop_Backup
Permissions Are Fine....

ln -s /sbin/init.d/Start_Backup
/sbin/rc3.d/S756Backup
ln -s /sbin/init.d/Stop_Backup /sbin/rc2.d/K982Backup

Here I attached the Script as given by DP...
But Where I need to Copy this File in /sbin/init.d or in /etc/rc.config.d directory..

Whether this file is Enough for Starting & Killing or I need to Creare One more file for Killing ....

Pls Clarify......

---------------------------------------------

If Not So Clear:-
THE SCRIPT /SBIN/INIT.D/BACKUP

I WANT TO START IN RUNLEVEL 3 & KILL AT LEVEL 2.
PROVIDE ME THE FILE THAT WILL DO THIS ...
Devesh Pant_1
Esteemed Contributor

Re: Executing Script While System Booting...

Sundar,
you are fine there all you need to do is to check the permissions on the script /sbin/init.d/backup
remove the links you created earlier
by doing
cd /sbin/rc3.d
rm S756Backup
and
cd /sbin/rc2.d
rm K982Backup

recreate the links as follows
ln -s /sbin/init.d/backup
/sbin/rc3.d/S756Backup
ln -s /sbin/init.d/backup /sbin/rc2.d/K982Backup

Just a note:
The numbers ( S756 and K982) although you can use whatever you want but the recommended way is to substract the start number from 1000 and use it for the kill script. So if possible use S756 and K244

thanks
DP
Devesh Pant_1
Esteemed Contributor
Solution

Re: Executing Script While System Booting...

Sundar,
I am assuming here that my script that you have accurately modified is copied as
/sbin/init.d/backup

thanks
DP
susee_sundar
Regular Advisor

Re: Executing Script While System Booting...

Hi Thanks Dp & to All...