2

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?

3 Answers3

4

I ended up figuring this out. CentOS6 uses upstart as its init program, but one of the scripts it initializes in /etc/init is rc.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.

0

You can check process sshd with pidfile /var/run/sshd.pid in your script to make sure it is running.

  if [ -f /var/run/says.pid]; then
     "do what you want with your script"
  fi

You can put logic inside where you can sleep after check for sshd if the pid is not there yet.

0

Just add your script to the /etc/rc.d/rc.local. Your script will be executed after all the other init scripts.

ALex_hha
  • 7,415