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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Startup script at bootup rh7.1

Status
Not open for further replies.

coper

Technical User
Jan 4, 2002
36
US
Hi,

On redhat 7.1 if you want to startup a shell script (bla.sh) automatically on boot, do I put the script in /usr/etc/rc.d?

Do I need to make entries anywhere else.

Thank you.


 
Normally I would place entries like this in the rc.local file in /etc/rc.d/ directory. I have never tried placing a script in the /etc/rc.d/ directory, for all you know it may even work.

Anyone else tried it? IBM Certified Specialist - MQSeries
 
Well, you can always put the script in /etc/rc.d/init.d then make a symbolic link to that script in the default runlevel directory, with a Sxx to start it. What I do, is take an existing script in /etc/rc.d/init.d and hack it up to fit my needs. You can then make a symbolic link to that script in your /etc/rc.d/rc0.d and /etc/rc.d/rc6.d and prefix it with a Kxx so it gets shutdown properly. Bruce Garlock
bruceg@tiac.net
 
Hi,



For simple stuff you'd place code directly in the /etc/rc.d/rc.local script.



If you want someting that starts/stops at runlevels you can quite easily make a sysv init script by looking at the existing ones in /etc/rc.d/init.d . You don't need to bother with that hassle of doing the symlinks due to the wonder of 'chkconfig'. For example from this snippet :



#!/bin/sh

#

# Startup script for Tomcat, the Apache Servlet Engine

#

# chkconfig: 345 80 20



Note the 'chkconfig' line. The values mean the service should be 'on' at levels 345 and have start / stop priorities of 80 and 20 (for the S & K prefixed symlnks) . All you do is create your script which must accept at least 'start' and 'stop' as arguments, put it in /etc/rc.d/init.d and then add to the sysv process with :



/sbin/chkconfig --add yourscriptname



That will create the symlinks based on the 'chkconfig' line in the script itself, as described above.



After that you can treat your script the same as any other sysv init script.



Hope this helps



 
Thanks folks - I got it going

>chkconfig did the trick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top