Is there a way to determine if there is a job running in a jetstream container?

  • 0
  • 1
  • Question
  • Updated 2 years ago
  • Answered
Photo of Jim Daniels

Jim Daniels

  • 150 Points 100 badge 2x thumb

Posted 2 years ago

  • 0
  • 1
Photo of Adam Bowen

Adam Bowen, Official Rep

  • 17,420 Points 10k badge 2x thumb
Official Response
Sure. I do simple checks like that in my automation. Take a look at this shell function that I wrote that takes a reference id (all delphix objects have one) and waits for the jobs to complete.

function RUNNING_JOBS_WAIT { #This function wais for jobs to finish on the specified target
#Takes one parameter: The target reference
TARGETREF=$1
until [[ 1 -gt 2 ]]; do
fJOB=$(curl -X GET -k "http://${DEIP}/resources/json/delphix/job?target=${TARGETREF}&jobState=RUNNING"; \
-b ~/cookies.txt -H "Content-Type: application/json"| jq -r ".result[].reference")
if [[ -n ${fJOB} ]]; then
echo "Waiting on $fJOB to complete"
sleep 5
else
break
fi
done
echo "Job's done"
}