Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On a centos 6 derivative (Amazon Linux), I have an init.d script ecrinit that is meant to enable/disable some services at system startup (based on contents of a properties file on disk):

if [[ "$nodeType" == "foo" ]]; then
 #turn off mysql, turn on proftpd
 service mysqld stop
 chkconfig mysqld off # prevent lower-pri mysqld service from 

 chkconfig proftpd reset # re-enables at run levels 2-4

Since start pri of ecrinit is 60 and of proftpd is 88, I expected the latter to be started by the boot process, since calling chkconfig reset above ensured that appropriate files exist in /etc/rc3.d (confirmed).

But that does not seem to be the case, as 'start' is never called on proftpd (I added a log statement to latter script's body to confirm) if I issue 'chkconfig proftpd off' before doing 'init 6'. In other words, it seems that the boot process checks contents of /etc/rc3.d before ecrinit is executed (and does not detect new files in same dir during boot process)...

Is that the expected behavior? If so, how can i control which services should be enabled on a given startup (and avoid manually starting them to preserve priority order)?

startup script heads

[root@lb1 ~]# head /etc/init.d/proftpd
# $Id: proftpd.init,v 1.1 2004/02/26 17:54:30 thias Exp $
# proftpd       This shell script takes care of starting and stopping
#               proftpd.
# chkconfig: 234 88 12
# description: ProFTPd is an enhanced FTP server with a focus towards \
#              simplicity, security, and ease of configuration. \
#              It features a very Apache-like configuration syntax, \
[root@lb1 ~]# head /etc/init.d/ecrinit
# chkconfig: 234 19 10
# description: Initializes stuff

chkconfig --list (after boot)

[root@lb1 rc3.d]$ chkconfig --list proftpd
proftpd         0:off   1:off   2:on    3:on    4:on    5:off   6:off
[root@lb1 rc3.d]$ chkconfig --list ecrinit
ecrinit         0:off   1:off   2:on    3:on    4:on    5:off   6:off

uname -a Linux #1 SMP Mon Oct 24 16:03:22 UTC 2011 i686 i686 i386 GNU/Linux

share|improve this question
up vote 2 down vote accepted

Take a look at the /etc/rc script, which does the following:

for i in /etc/rc$runlevel.d/S* ; do

the script has already expanded the list of available startup scripts before they run; changes made via chkconfig (or direct filesystem manipulation) aren't going to be visible.

If you move your logic to the end of the boot process, you can start the services explicitly:

if [[ "$nodeType" == "foo" ]]; then
 #turn off mysql, turn on proftpd
 service mysqld stop
 chkconfig mysqld off # prevent lower-pri mysqld service from 

 service protftpd start

There's probably not much point in using chkconfig to enable proftpd in this example, since presumably the logic here will start it anyway next time the system boots.

You may also want to investigate puppet, which is good at doing exactly this sort of thing.

share|improve this answer
thx - for pointing to /etc/rc & puppet – Nikita Mar 14 '12 at 16:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.