Posted By

noah on 10/28/10


Shell Bash control hacks Poll programming while tips tricks sysadmin selenium wait service nc netcat

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


bash: how to start a service and wait until it's up

 / Published in: Bash

Sometimes you need to start a service that takes a while to spin up.

Solr and Selenium-RC Server, for instance, can be unavailable for several seconds after the command to start them is issued.

Using Netcat, it's easy to poll-and-wait until a newly-started service begins listening on its proper port.

  1. selenium-rc &
  3. while ! nc -vz localhost 4444; do sleep 1; done
  5. echo 'Selenium-RC server is open for business on port 4444!'

Report this snippet  

You need to login to post a comment.