How do you determine if an upstart job is running inside of a Bash script? That is I need a "boolean" value to do something like:
#!/bin/bash
if [ determine_if_job_x_is_running ]; then
echo "I see upstart job X is running, please stop it before ..."
fi
Best Answer
Create your own Bash function and put this in your
~/.bashrc
:I really dislike the way of parsing output, but I don't see another obvious way. And in this case the output of
<service name> start
is very reliable as it's specified in the Upstart documentation.Now you can use it like this: