4

On RHEL 6.3, I have a system service that should be starting after postgresql and httpd (order 64 and 85, respectively), but chkconfig always places it at order 50. I tried an experiment on a CentOS 6.0 virtual machine to make sure I understood the LSB stanza syntax.

I created /etc/init.d/foo, owner root, permissions 755, with this text:

### BEGIN INIT INFO
# Provides: foo
# Required-Start: postgresql httpd
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Foo init script
### END INIT INFO

And then ran chkconfig --add foo. Result: /etc/rc5.d/S86foo is created, as expected. (The other runlevels are also as expected.)

I repeated the exact same experiment on the RHEL machine, and it created /etc/rc5.d/S50foo instead. I can't see anything different between the two that would lead to different results. Both machines have postgresql and httpd starting at the same orders and runlevels. Any thoughts? I could just use # chkconfig: 2345 86 50, or manually rename the service symlinks to the correct order, but I'm trying to document an install process for later users, and I want to know how to do it right and understand why it's not working as expected.

Robert
  • 41
  • 3
  • Your logic is correct. They should act the same. As a test, try changing the required start services to something else and see if it still drops it in order 50. The chkconfig man page suggests that the required start services must be enabled but it sounds like you've already confirmed that. – kernelpanic Nov 04 '12 at 01:42
  • Do you have the same number of services in /etc/init.d on both machines? Isn't that number in the symlink just so that when init runs them, it evaluates them in the same order that ls would evaluate them? Is it possible that you have 85 startup scripts on CentOS but only 49 on Red Hat? –  May 21 '13 at 21:30
  • Do you have anything in /etc/chkconfig.d/ ? – Mark Cohen Jun 18 '13 at 19:46

1 Answers1

1

On RH systems you must use chkconfig line as documented:

https://fedoraproject.org/wiki/Packaging:SysVInitScript#.23_chkconfig:_line

Regarding chkconfig line:

The chkconfig: line in a SysV-style initscript is used to determine the runlevels in which the service should be started by default. It is also used to set the "priority", or order in which the services are started within a runlevel. All Fedora SysV-style initscripts must have this line.

Regarding LSB header:

Each Fedora SysV-style initscript which needs to start by default in any runlevel must include this line in the LSB Header, and it must match the list of runlevels defined for startup in the Chkconfig header.

GioMac
  • 4,544
  • 4
  • 27
  • 41