Quote:
Originally Posted by mrlinux2000
thanks,
and the script to be start at the start of the system
|
No, he means that you type
once and that from then on, httpd will start automatically.
But that doesn't really answer your question, because you said
Quote:
want a service to be started at the start of the system, what ever bind or apache or squid ...HTTPD just an example
|
and that's the problem, because there are multiple possibilities for starting things up.
This is actually a very complicated subject. You can start things in /etc/inittab. For the moment I'll ignore distros that don't use inittab or are in transition ( Ubuntu in the Linux world is transitioning to Upstart, BSD and Mac OS never used inittab ).
You can also start things by putting scripts into the directories that existing inittab entries run through. Some of these scripts already exist in an unactivated state and that's what "chkconfig" does on systems that support it - it makes links into appropriate directories to scripts and those scripts will be run at startup because inittab runs a script that looks for those and runs.
So, for example, inittab runs /etc/rc and passes it a runlevel argument. If that's 5, scripts in /etc/rc5.d are run. AS I said, :"chkconfig" just activates these:
Code:
# pwd
/etc/rc5.d
# ls *httpd
K15httpd
# chkconfig httpd on
# ls *httpd
S85httpd
# chkconfig httpd off
# ls *httpd
K15httpd
#
Scripts that begin with K are "kill scripts" - they stop the service. "S" scripts start it. Actually they are the same script (a link to /etc/rc.d/init.d/httpd) , but the /etc/rc script calls "S" scripts with "start" as an argument and "K" scripts get passed "stop". If you look at script, you'll see how it parses the arguments.
You could also just add entries to a script that always runs. On almost all systems, there's a "/etc/rc.local" script. You COULD add "service httpd start" to that or "/etc/rc.d/init.d/httpd start" to /etc/rc.local, but the advantages of letting chkconfig and the rc scripts handle it should be obvious.
Another place for daemons is in /etc/xinted.d but this is long enough already.
I put additional info (like how to add your own script to chkconfig) at
http://aplawrence.com/Basics/unix-st...scripts-1.html