Main Content

demote

Demote job in cluster queue

Syntax

demote(c,job)

Arguments

c

Cluster object that contains the job.

job

Job object demoted in the job queue.

Description

demote(c,job) demotes the job object job that is queued in the cluster c.

If job is not the last job in the queue, demote exchanges the position of job and the job that follows it in the queue.

Examples

Create and submit multiple jobs to the cluster identified by the default cluster profile, assuming that the default cluster profile uses a MATLAB® Job Scheduler.

c = parcluster;

Use pause to prevent submissions from running.

pause(c) % Prevent submissions from running.

Create jobs and tasks and submit to queue.

j1 = createJob(c,'Name',"Job A");
t1 = createTask(j1,@rand,1,{10,10});
j2 = createJob(c,'Name',"Job B");
t2 = createTask(j2,{@rand,@magic,@ones},1,{{3,3} {3} {3,3}});
j3 = createJob(c,'Name',"Job C");
t3 = createTask(j3,@rand,1,{10,10},CaptureDiary=true);
submit(j1);submit(j2);submit(j3);

Examine the queue sequence.

[pjobs,qjobs,rjobs,fjobs] = findJob(c);
get(qjobs,'Name')
    'Job A'
    'Job B'
    'Job C'

Demote Job A by one position in its queue.

demote(c,j1)

Examine the new queue sequence.

[pjobs,qjobs,rjobs,fjobs] = findJob(c);
get(qjobs,'Name')
    'Job B'
    'Job A'
    'Job C'

Resume processing of the job queue.

resume(c)

Tips

After a call to demote or promote, there is no change in the order of job objects contained in the Jobs property of the cluster object. To see the scheduled order of execution for jobs in the queue, use the findJob function in the form [pending queued running finished] = findJob(c).

Version History

Introduced before R2006a