4 Replies Latest reply on Mar 5, 2013 8:56 AM by John NameToUpdate

    blcli BatchJob executeJobAndWait $JOBKEY

      I am using this command in a nshell script, but unfortunately it fails about 25% of the time. "Fails" as in fails to capture the handle to the job. The actual batchjob that it initiates is executed successfully and completes.


      It is the exact same line of code in the same script that just happens to work on some runs but not all. Is there a known defect with this command randomly returning an error that isn't an actual error? I'm on version 7.6


      Additonally, I don't use this command with blcli_storeenv, instead I use :


      VAR=`blcli BatchJob executeJobAndWait $JOBKEY`


      Would this have an effect with issues in losing the handle?


      Thanks so much!


        • 1. Re: blcli BatchJob executeJobAndWait $JOBKEY
          Siddu angadi

          VAR=`blcli BatchJob executeJobAndWait $JOBKEY`

          Yes, if use as above, somtime bladelogic does not capture the values. It might be a bug.


          Use commands as mentioned below:


          blcli_execute BatchJob executeJobAndWait $JOBKEY

          blcli_storeenv result

          echo ${result}


          Always use Performance commands to improve the speed of execution and performance of job/


          Performance commands are :


          • blcli_execute
          • blcli_storeenv







          1 of 1 people found this helpful
          • 2. Re: blcli BatchJob executeJobAndWait $JOBKEY

            Siddu, the change to the performance commands above seemed to have helped in that we have no longer seen the issue of losing the handle to the job; however, I now have incidences where the executeJobAndWait is not waiting, so my script continues processing and checks to see if it had errors or not - "getJobRunHadErrorsById" - which shows it was successful when in fact it was still running and had not completed.


            Example snippet:


            blcli_execute BatchJob executeJobAndWait "$JOB_KEY"
            blcli_storeenv RUN_KEY
            echo RUN KEY is: $RUN_KEY
            RUN_ID=`blcli JobRun jobRunKeyToJobRunId "$RUN_KEY"`
            echo RUN ID is: $RUN_ID
            BATCH_STATUS=`blcli JobRun getJobRunHadErrorsById "$RUN_ID"`
            echo BATCH_STATUS is: $BATCH_STATUS

            if [ "$BATCH_STATUS" = "true" ]
                   echo Batch job failed
                   exit 1
                   echo Batch job completed successfully

            • 3. Re: blcli BatchJob executeJobAndWait $JOBKEY
              Bill Robinson

              you should be using performance commands in the whole script...  and why are you exiting your script if it's sitll running?  why not loop to see if it's running and wait till its done ?

              • 4. Re: blcli BatchJob executeJobAndWait $JOBKEY

                Bill you're correct. I am converting my other commands to performance commands as well. In answer to your question, there is obviously a huge chunk of my script ommited here. Suffice it to say that I need to exit this script if the spawned Batch job fails. The placement of my check for the Batch run status is after method "getJobRunHadErrorsById" which is only hit after the batch job completes - or should be completed if the executeJobAndWait works correctly right?


                Are you refering to a loop with method "getJobRunIsRunningByRunKey" ? It wouldn't work for instances when the executeJobAndWait doesn't return a handle (RunKey), so guess I can insert those other methods to obtain the runkey findLastRunKeyByJobKey or something........that should work just fine for a solution in case I lose the Handle.


                The major outstanding issue now is blcli JobRun getJobRunHadErrorsById "$RUN_ID". It isn't accurate with the boolean it returns. Yesterday, 2 of 7 runs of the above script this method returned false, when in actuality the batch job failed with errors.