Operating System - Linux
1827882 Members
1161 Online
109969 Solutions
New Discussion

new init.d startup script

 
SOLVED
Go to solution
Jeff Hoevenaar
Frequent Advisor

new init.d startup script

Is there any good docs to explain the format of the RedHat Linux startup scripts in /etc/init.d. I want to create a customized script for my application. Or is there a template script on the syste, somewhere that I can use.

Thanks.
4 REPLIES 4
Denver Osborn
Honored Contributor

Re: new init.d startup script

man init.d

The manual page should give you enough info to build your stratup script. If there's a template for RH the init.d man page should point you to it. I'm more familiar w/ SuSE and their template it /etc/init.d/skeleton... You should check out the man page.

If you can't find the template on RH, copy en existing script and make your changes. The script will go in /etc/init.d w/ symbolic links in /etc/init.d/rc?.d/K???script or S???script. Where rc?.d is the runlevel to start/stop and K???script is for the shutdown, S??? is run at startup. Example

/etc/init.d/myscript

ln -s /etc/init.d/myscript /etc/init.d/rc3.d/S600myscript

ln -s /etc/init.d/myscript /etc/init.d/rc2.d/K600myscript


"myscript" will startup in runlevel 3... man page should cover it all.

hope this helps,
-denver
Eric van Dijken
Trusted Contributor
Solution

Re: new init.d startup script

Hi,

This webpage below will tell you all you need. I think there used to be a RPM, which had a bare bone application startup/shutdown script. But the name is lost to me as thats a long time ago (+3 years ago)

http://www.sensi.org/~alec/unix/redhat/sysvinit.html

Another usefull manualpage is: "man chkconfig"

But if that all fails, try to find one that almost has what you need. And copy and change that one to your needs.


Watch, Think and Tinker.
Magnus Andersen
Advisor

Re: new init.d startup script

On RH Linux you can create a custom script and place it in /etc/rc.d/init.d

Place the chkconfig and description lines lines at the top of the script. See code below.

As root run chkconfig --add scriptname

To verify run chkconfig --list scriptname

That should show you what runlevels the script will start/stop.

You can also utilize the service command once this is done.

service scriptname start/stop/status


#!/bin/bash
################################################################
# Oracle startup/shutdown script
# chkconfig: 2345 99 10
# description: starts and stops the Oracle databases
Ross Minkov
Esteemed Contributor

Re: new init.d startup script