Question: I am trying find out, how to start JBoss with cron job at a particular time. 

What I am doing at the moment is setup a cron, then inside JBoss startinstance script I put sleep 700 seconds until jboss starts.

Is there a better way to actually know when JBoss has successfully started and then continue with the flow after, instead of sleeping for 700 seconds? Did anyone do something similar?

I have got something like this, and I do not think this is the right solution :

```
#!/bin/ksh
#This script accepts one parameter URL which should to tracked

usage() {
    msg=${1}
    echo "ERROR: "
    exit 1
}

args_no=$#

if [[ ${args_no} -ne 1 ]]; then
    usage
fi

URL_to_check=${1}

jboss_status=1

while [[ ${jboss_status} -ne 0 ]]; do
    wget ${URL_to_check} > /dev/null
    jboss_status=$?
    sleep 10
done

exit 0  

```

Answer: 
You could poll your log file and check for the line

```
ServerImpl.info: JBoss.*Started in

```

and sleep in between the polls. For instance:

```
LOG_FILE=/path/to/jboss.log
start_info=''

while [[ ! -n "${start_info}" ]]; do
    start_info=`grep "ServerImpl.info: JBoss.*Started in" $LOG_FILE`
    sleep 10
done

```
The [JBoss Maven plugin](http://mojo.codehaus.org/jboss-maven-plugin/) has a [`start-and-wait`](http://mojo.codehaus.org/jboss-maven-plugin/start-and-wait-mojo.html) goal which does what you are looking for by checking server state via the JNDI port. If this sounds compelling, you could peek into the source code to see how it does what it does.