Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shutdown script in ../rc2.d/ 1

Status
Not open for further replies.

cipaera

Technical User
May 14, 2007
24
NL
Hi everyone...

I want to run 3 scripts (in init.d) as one script (in rc2.d) using "sleep nnn" in between.
(/etc/rc.d/init.d/: script1, script2, script3)

This is what I've tried:
/etc/rc.d/rc2.d/S90_all_of_scripts:
#!/bin/ksh
/etc/rc.d/init.d/script1 $1
sleep 300
/etc/rc.d/init.d/script2 $1
sleep 300
/etc/rc.d/init.d/script3 $1

But it seems like those scripts didn't run like they should be. :(
# shutdown -Fr
<snip>
Usage: /etc/rc.d/init.d/script1 (start | stop)
Usage: /etc/rc.d/init.d/script2 (start | stop)
Usage: /etc/rc.d/init.d/script3 (start | stop)
<snip>

Could anyone help me to understand, what I've done wrong with S90_all_of_scripts?
More over... how can I use elegantly "sleep nnn" between script1-3 when I shutdown the system?

Thanks in advance.
 
I don't use rcX.d scripts when shutting down, I prefer using the script /etc/rc.shutdown

This script is read when shutting down, so you can put your 3 scripts, with parameter stop, in this one.
 
Thanks MoreFeo,

But there is a situation, which I can't live with.

From the manual of 'shutdown':
If the script runs but fails with a non-zero return code, the shutdown stops.

I hope there is another way...
 
cant you just -

1) create your script1/2/3 in /etc/rc.d/init.d
2) create symbolic links in /etc/rc.d/rc2.d for the above scripts
3) ensure the entries in /etc/rc.d/rc2.d are named
correctly so that /etc/rc.d/rc sorts them in the correct order to execute
4) ensure script1/2 have a sleep 300 as the last line
 
tempest92: thanks for the idea, but I can not use the procedure... because the scripts may not be changed.

Any other suggestion?
 
Well.. FYI... it was my fault.
I did edit only the S##script but forgot to edit the K##script.

/etc/rc.d/rc#.d/K90_all_of_scripts should also look like
/etc/rc.d/rc#.d/S90_all_of_scripts:
#!/bin/ksh
/etc/rc.d/init.d/script1 $1
sleep 300
/etc/rc.d/init.d/script2 $1
sleep 300
/etc/rc.d/init.d/script3 $1

Now everything looks fine. ;)

Regards,
cipaera
 
cipaera - you deserve a star both for posting your solution and admitting it was your fault (a very rare occurrence in IT unfortunately). Well done.

I want to be good, is that not enough?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top