Main Content

findJob

Find job objects stored in cluster

    Description

    example

    objArray = findJob(cluster) returns an array, objArray, of all job objects stored in the cluster c. Jobs in the array are ordered by the ID property of the jobs, indicating the sequence in which they were created.

    example

    objArray = findJob(cluster,propertyName,propertyValue) returns an array, objArray, of job objects that have a property called propertyName with a value of propertyValue. See parallel.Job for a list of job properties.

    For a match, the object property value must be exactly the same as specified, including letter case. For example, if a job’s Name property value is MyJob, then findJob will not find that object while searching for a Name property value of myjob.

    example

    objArray = findJob(cluster,propertyName1,propertyValue1,...,propertyNameN,propertyValueN) returns an array, objArray, of job objects that meet all the property names and property values in the search criteria.

    example

    [pending,queued,running,completed] = findJob(objArray,___) sorts all job objects stored in the cluster c by state. Within pending, running, and completed, the jobs are returned in sequence of creation. Jobs in the array queued are in the order in which they are queued, with the job at queued(1) being the next to execute. The completed jobs include those that failed. Jobs that are deleted or whose status is unavailable are not returned by this function.

    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 IDs 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 with different names and tags 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 the Tag property value of testing.

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

    Finally, narrow down the list of jobs with the Tag property value of testing by adding another search criteria 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 find the job, specified as a parallel.Cluster object that represents cluster compute resources. To create a cluster object, use the parcluster function.

    Example: cluster = parcluster; findJob(cluster);

    Data Types: parallel.Cluster

    Job object property name to find, specified as a string scalar or character vector. If you specify more than one name-value pair, the returned entries meet all of the 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.

    Data Types: char | string

    Values of job object property to find, specified as a string scalar or character vector. If you specify more than one proper name - property value pair, the returned entries meet all of the 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.

    Data Types: char | string

    Output Arguments

    collapse all

    Jobs found in cluster, returned as an array of parallel.Job objects.

    Data Types: parallel.Job objects

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

    Data Types: parallel.Job object

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

    Data Types: parallel.Job object

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

    Data Types: parallel.Job object

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

    Data Types: parallel.Job object

    Version History

    Introduced before R2006a