This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Cancel job or task





Pending or running task to cancel.


Pending, running, or queued job to cancel.


cancel(t) stops the task object, t, that is currently in the pending or running state. The task’s State property is set to finished, and no output arguments are returned. An error message stating that the task was canceled is placed in the task object's ErrorMessage property, and the worker session running the task is restarted.

cancel(j) stops the job object, j, that is pending, queued, or running. The job’s State property is set to finished, and a cancel is executed on all tasks in the job that are not in the finished state. A job object that has been canceled cannot be started again.

If the job is running from an MJS, any worker sessions that are evaluating tasks belonging to the job object are restarted.

If the specified job or task is already in the finished state, no action is taken.


Cancel a task. Note afterward the task’s State, ErrorIdentifier, and ErrorMessage properties.

c = parcluster();
job1 = createJob(c);
t = createTask(job1, @rand, 1, {3,3});
 Task with properties: 

                   ID: 1
                State: finished
             Function: @rand
               Parent: Job 1
     Running Duration: 0 days 0h 0m 0s

      ErrorIdentifier: parallel:task:UserCancellation
         ErrorMessage: The task was cancelled by user "mylogin" on machine

See Also


Introduced before R2006a

Was this topic helpful?