Main Content

findJob

Find job objects in cluster

    Description

    objArray = findJob(cluster) returns an array of all job objects in the cluster cluster. The jobs in the array are in order of their ID property, indicating the sequence in which they were created.

    example

    objArray = findJob(cluster,propertyName=Value) specifies properties and values to find, using one or more property name-value arguments. For a list of job properties, see parallel.Job.

    The object property value must match the specified value exactly. For example, if the Name property value of a job is MyJob, then findJob does not find that object when it searches for a job with the Name property value of myjob.

    example

    [pending,queued,running,completed] = findJob(___) sorts all the job objects stored in the cluster by state. Within the pending, running, and completed job arrays, the software returns the jobs in order of their ID property. Jobs in the queued job array are in the order in which the scheduler queues them, where the job corresponding to queued(1) is the next to execute. The completed jobs include those that failed. This function does not return jobs that are deleted or whose status are unavailable.

    example

    Examples

    collapse all

    Create a cluster using the default profile and use batch to submit a random number of jobs to the cluster.

    myCluster = parcluster;
    numJobs = randi(50);
    for idx = 1:numJobs
        job = batch(myCluster,@magic,1,{idx});
    end

    Find the number of jobs submitted to the cluster.

    objArray = findJob(myCluster);
    whos objArray
      Name           Size            Bytes  Class                             Attributes
    
      objArray      10x1                80  parallel.job.CJSIndependentJob              
    

    Determine the State property of the jobs submitted to the cluster.

    [pending,queued,running,completed] = findJob(myCluster);

    List the ID properties of the jobs in the completed state.

    completed.ID
    ans = 120
    
    ans = 121
    
    ans = 122
    
    ans = 123
    

    Create a cluster using the default profile and use createJob to submit jobs to the cluster.

    myCluster = parcluster;
    job1 = createJob(myCluster,Tag="testing");
    job2 = createJob(myCluster,Name="MonteCarlo",Tag="testing");
    job3 = createJob(myCluster,Name="MonteCarlo2",Tag="testing");

    Find jobs with a Tag property value of testing.

    objArray = findJob(myCluster,Tag="testing");
    objArray.Name
    ans = 
    'Job23'
    
    ans = 
    'MonteCarlo'
    
    ans = 
    'MonteCarlo2'
    

    Finally, narrow down the list of jobs with a Tag property value of testing by adding another search criterion in the form of the Name property value MonteCarlo.

    objArray = findJob(myCluster,Name="MonteCarlo",Tag="testing");
    objArray.Name
    ans = 
    'MonteCarlo'
    

    Input Arguments

    collapse all

    Cluster in which to search for the job, specified as a parallel.Cluster object that represents cluster computing resources. To create a cluster object, use the parcluster function.

    Job object property name and value to find, specified as a parallel.job property name-value argument. If you specify more than one property name-value argument, findJob returns entries that meet all of the search criteria. For a full list of job object properties, see parallel.Job.

    Example: findJob(cluster,Username="jsmith") finds job objects that have the Username property value of jsmith.

    Output Arguments

    collapse all

    Jobs in the cluster that meet the search criteria, returned as an array of parallel.Job objects.

    Jobs in a pending state on the cluster, returned as an array of parallel.Job objects.

    Jobs in a queued state on the cluster, returned as an array of parallel.Job objects.

    Jobs in a running state on the cluster, returned as an array of parallel.Job objects.

    Jobs in a completed or failed state on the cluster, returned as an array of parallel.Job objects.

    Version History

    Introduced before R2006a