locked
ISchedulerJob.State always returns 1 RRS feed

  • Question

  • Hi,

    I'm using VB script for submitting job to HPCS R2 (SP2) Scheduler.

    I'd like to get a status of the job in VB script to wait until job finished.

    In the following script, job.State always returns 1 even if job is running or finished.

    ------------------------------------

    Set objHpcScheduler = CreateObject("Microsoft.Hpc.Scheduler.Scheduler")
    objHpcScheduler.Connect(strClusterName)

    Set objJob = objHpcScheduler.CreateJob
    objJob.Name = strJobName

    objJob.MaximumNumberOfCores = intCPU
    objJob.MinimumNumberOfCores = intCPU

    objHpcScheduler.AddJob((objJob))
    intJobID = objJob.Id

    Set objTask = objJob.CreateTask

    objTask.MaximumNumberOfCores = intCPU
    objTask.MinimumNumberOfCores = intCPU

    objTask.CommandLine = strCommandLine
    objTask.WorkDirectory = strWorkFolder

    objTask.StdOutFilePath = strStdOutFilePath
    objTask.StdErrFilePath = strStdErrFilePath

    objJob.AddTask(objTask)

    objHpcScheduler.SubmitJobById intJobID, null, null

    Do While objJob.State < 128
     WScript.Sleep(1000)
     WScript.Echo "Id-Status: " & objJob.Id & "-" & objJob.State
    Loop
    ------------------------------------

    objJob.Id returns correctly but objJob.State returns

    Is there something wrong in my scripts?

     

    Regards,

    Hirakata

    Wednesday, July 20, 2011 8:27 AM

Answers

  • My problem is solved.

    It is necessary to update job status using using Refresh().

    --------------------------------------------

        Do While objJob.State < 128
            WScript.Sleep(3000)
            objJob.Refresh
        Loop
    --------------------------------------------

     

     

    Thursday, July 21, 2011 12:11 AM