Ubuntu – How to change the order of execution of services at startup

14.04init.dservicesstartup

I have some services in my init.d folder for e.g. hdfs, zookeeper, elasticsearch, hbase and so on.

Now, I have added all those services to startup by doing the update-rc.d 'service' defaults command. As we know, hbase can't run if hdfs and zookeeper are not started. So I want to start hdfs first, then zookeeper and then finally hbase.

how do I do this?

Best Answer

update-rc.d(8) enables or disables services, while the ordering of services is handled by insserv(8), and can be customized by editing the LSB header of the service and setting/adding:

Required-Start: $all

In oldest versions, i can do something like this to determine the order:

update-rc.d myservice start 95 2 3 4 5 . stop 70 0 1 6 .

But after Ubuntu 14, i tried this Ubuntu 16.04 (4.4.0-31-generic):

update-rc.d myservice defaults 95 70

And doesn't work, always creates the order defined in the header:

 sudo find /etc/ -name ???myservice | sort
/etc/rc0.d/K01myservice
/etc/rc1.d/K01myservice
/etc/rc2.d/S03myservice
/etc/rc3.d/S03myservice
/etc/rc4.d/S03myservice
/etc/rc5.d/S03myservice
/etc/rc6.d/K01myservice

Also al try:

update-rc.d myservice defaults any_text_wath_you_want lalala

Ands seems like ignores all the text after "defaults". I donĀ“t know wath it do when my installation order, I do not think that orders previously installed services.