LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Are all scripts in /etc/init.d automatically executed at startup? (https://www.linuxquestions.org/questions/linux-newbie-8/are-all-scripts-in-etc-init-d-automatically-executed-at-startup-906721/)

pstein 10-06-2011 06:14 AM

Are all scripts in /etc/init.d automatically executed at startup?
 
Are all scripts in /etc/init.d automatically executed at startup?

Or do I have to saved them there AND to activate them explicitely?

Are these scripts executed before starting other possible services (ssh, mailer, ...) or are they executed at the end of all startup processing?

Peter

evo2 10-06-2011 06:51 AM

Hi,

Quote:

Originally Posted by pstein (Post 4491461)
Are all scripts in /etc/init.d automatically executed at startup?

No they are not.
Quote:

Or do I have to saved them there AND to activate them explicitely?
Something like that that. On a sysvinit style system there will be symlinks from various scripts in /etc/init.d/
to /etc/rcN.d/ (where N is a positive intiger) prepended with and S or a K and a two digit number. Scripts starting with S(K) will be started(sopped) at run level N, There should also be a /etc/rcS.d/, these scripts are run at startup regardless of the runlevel.

Quote:

Are these scripts executed before starting other possible services (ssh, mailer, ...) or are they executed at the end of all startup processing?
The order they are started depends on the two digit number in the symlink. For example on my system, the default runlevel is 2 (N=2) and in /etc/rc2.d/ I have S04ssh and S06cups (and many others). This tells me that ssh is started before cups. Check your /etc/inittab to find out your default runlevel.

Please note that this is just a very rough overview and that there is plenty of detailed information available on the web and most probably in the man pages on your system. Also please note that these days there are other init systems such as upstart and systemd.

Cheers,

Evo2.

d3vrandom 10-06-2011 06:53 AM

They are not automatically executed. You have to choose which ones run automatically in which run level. In centos/redhat/fedora/(open)suse you do this via the chkconfig command:

Code:

chkconfig --list
Will show which services run on which run level.

Code:

man chkconfig

the above will get you the chkconfig documentation.

pstein 10-06-2011 08:04 AM

Quote:

Originally Posted by d3vrandom (Post 4491474)
They are not automatically executed. You have to choose which ones run automatically in which run level. In centos/redhat/fedora/(open)suse you do this via the chkconfig command:

Code:

chkconfig --list
Will show which services run on which run level.



Ok. thank you.

Do these services have to be binary programs or can I specify a perl/shells script as well?

Can I use user defined scripts here at all?

d3vrandom 10-06-2011 08:40 AM

Most of the files in /etc/init.d are actually shell scripts.

Unless you are installing a daemon from source you should avoid creating anything in /etc/init.d. Instead you should add your custom commands to /etc/rc.local (on redhat derived distros). Anyway you still haven't told us what distribution you are using. You can find out by running the following command:

Code:

cat /etc/issue

pstein 10-06-2011 09:19 AM

Quote:

Originally Posted by d3vrandom (Post 4491519)
Most of the files in /etc/init.d are actually shell scripts.

Unless you are installing a daemon from source you should avoid creating anything in /etc/init.d. Instead you should add your custom commands to /etc/rc.local (on redhat derived distros). Anyway you still haven't told us what distribution you are using. You can find out by running the following command:

Code:

cat /etc/issue

Great Thank you

CentOS and Ubuntu


All times are GMT -5. The time now is 03:28 PM.