LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-06-2011, 07:14 AM   #1
pstein
LQ Newbie
 
Registered: Jan 2009
Posts: 13

Rep: Reputation: 0
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
 
Old 10-06-2011, 07:51 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
Hi,

Quote:
Originally Posted by pstein View Post
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.
 
1 members found this post helpful.
Old 10-06-2011, 07:53 AM   #3
d3vrandom
Member
 
Registered: Jun 2006
Location: Karachi, Pakistan
Distribution: OpenSUSE, CentOS, Debian
Posts: 59

Rep: Reputation: 9
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.
 
Old 10-06-2011, 09:04 AM   #4
pstein
LQ Newbie
 
Registered: Jan 2009
Posts: 13

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by d3vrandom View Post
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?
 
Old 10-06-2011, 09:40 AM   #5
d3vrandom
Member
 
Registered: Jun 2006
Location: Karachi, Pakistan
Distribution: OpenSUSE, CentOS, Debian
Posts: 59

Rep: Reputation: 9
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
 
Old 10-06-2011, 10:19 AM   #6
pstein
LQ Newbie
 
Registered: Jan 2009
Posts: 13

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by d3vrandom View Post
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Startup scripts in init.d disappear after boot up lbuccola Programming 1 07-08-2010 11:52 AM
[SOLVED] Startup scripts don't get executed gusblake Fedora 2 06-23-2010 05:50 PM
RHEL3: init scripts aren't executed dabang Red Hat 2 01-04-2007 08:54 AM
Automatically run scripts on startup? Phaethar Fedora 10 09-24-2004 03:35 AM
startup scripts for init.d/ soredz Red Hat 2 10-16-2003 04:27 PM


All times are GMT -5. The time now is 11:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration