Results 1 to 7 of 7
Hi All,
I have written an init script and placed it in /etc/init.d/ directory.
What I would like to know is, will the script run automatically or
we need to ...
- 09-17-2010 #1Just Joined!
- Join Date
- Sep 2010
- Posts
- 4
Init scripts in /etc/init.d
Hi All,
I have written an init script and placed it in /etc/init.d/ directory.
What I would like to know is, will the script run automatically or
we need to install the script using "install_initd" command.
If I have to invoke this command manullay, what will be the best place to do this ? Can I add this to "/etc/init.d/rcS" file.
Thanks in advance,
Karthik.
- 09-17-2010 #2Just Joined!
- Join Date
- Aug 2010
- Posts
- 89
This is distro dependant. But simply placing the script in the init.d directory do nothing. You can use the 'service' command to start/stop the service.
e.g. # service xxxx command
If you put some ad-hoc comment in your script, you can use chkconfig to automaticaly link start and stop to various run-level
e.g. # chkconfig --level 345 xxxxx on
You should have this in your script :
# chkconfig: 345 40 60
345 = runlevels ; 40 and 60 are the order for start and stop
This work on red-hat/centos/mandriva. Don't know for other.
Take a look at :
# man chkconfig
- 09-17-2010 #3Just Joined!
- Join Date
- Apr 2010
- Posts
- 69
Debian-based distros have similar functionality to Redhat-based distros, but the commands are different. Regardless, on most distros, you should be able to type something like
to begin to find information on what you are looking for.Code:man -k init
- 09-18-2010 #4Just Joined!
- Join Date
- Jun 2006
- Posts
- 47
In Ubuntu one might just use System/Preferences/Startup Applications.
It's good for configuration scripts despite its GUI looks.
- 09-18-2010 #5Just Joined!
- Join Date
- Aug 2008
- Posts
- 7
/etc/init.d is the place to put startup and shut down scripts.
When linux starts up it goes thrpugh init stages. The startup 'commands' are stored in the /etc/rc (*).d directories. Check out the files already there.
The ones starting with 'K' are kill commands an the ones starting with 'S' are start commands.
/etc/rc2.d is probably where you should create a file S090mytask
/etc/init.d allows you to have only one copy of a task and be able to start it from any state.
- 09-18-2010 #6Linux Engineer
- Join Date
- Feb 2005
- Posts
- 1,044
If you look in, say rc3.d, you'll probably find the files in there are either symlinks to init.d or hard links to the init.d files. You just need equivalent K and S links to your script in the relevant rcN.d directories.
- 09-18-2010 #7Just Joined!
- Join Date
- Feb 2009
- Posts
- 3
The various bits of advice so far will show you how to get the script executed but a word of warning - unless you are absolutely certain about your script NEVER place at a run level below or equal to your system default level i.e. if you currently boot to level 2 by default DO NOT try your script out at level 1 or 2 - you may find you never get a prompt ! With a deault level of 2, place the script at level 3 and once you have a root shell type "init 3".


Reply With Quote