I'm running a CentOS6 instance and have an upstart job that depends on sshd to already be running. However when I boot up the box that job fails to start, I'm guessing because sshd isn't actually running yet. Is there a way I can delay upstart jobs from starting until all normal init scripts have started?
I ended up figuring this out. CentOS6 uses upstart as its init program, but one of the scripts it initializes in
/etc/init
isrc.conf
, which starts up the old-school rc scripts. So if you need your program to start AFTER those you can put:start on started rc stop on stopped rc
in your upstart script and you should be good to go.
You can check process sshd with pidfile /var/run/sshd.pid in your script to make sure it is running.
You can put logic inside where you can sleep after check for sshd if the pid is not there yet.
Just add your script to the /etc/rc.d/rc.local. Your script will be executed after all the other init scripts.