Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

On Ubuntu, to configure a service to start after network is up, you can put a script in your /etc/network/if-up.d/

#!/bin/sh
/etc/init.d/<your service> restart

or something like suggested in this superuser Q/A.

But I dont see the equivalent on Red hat. The only thing I found was using numbers in S/K files. I mean, is this the way to go in red hat?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Yep, that's the right way to go. You should use chkconfig which manages the init scripts for you.

The S?? and K?? numbers determine the priority so you should make sure that your service's number is higher than that of the 'network' (or NetworkManager) service.

share|improve this answer

The chkconfig definition at the start of an initscript determines what S/K number it gets.

Each "runlevel" is actually just a directory (/etc/rc*.d/) full of symlinks to initscripts (/etc/init.d/) and those symlinks are named with numbered S and K entries.

S means start and K means kill. When init enters a runlevel, it starts with S01 and works its way through to S99, running each initscript to start the service which that script controls. When init leaves a runlevel, it starts with K01 and works its way through to K99, running each script to stop the service which that script controls.

man chkconfig gives an example of both the chkconfig-style service definition, and the Linux Standards Base (LSB) style service definition.

If an initscript has both types defined, the LSB definition should take precedence over the chkconfig definition.

If you have a service which depends on network connectivity, you can either make sure your service starts after /etc/rc*.d/S10network by giving it a start number after 10, or you can see that /etc/init.d/network has the LSB definition Provides: $network, so you can use the LSB definition Required-Start: $network in your initscript.

share|improve this answer

Your Answer

 
discard

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.