cancel - Cancel job or task - MATLAB (original) (raw)

Main Content

Syntax

Description

cancel([t](#mw%5F0e02cb1a-269c-4e37-b4fd-a5dfd45fe4e6)) stops the task object,t, that is currently in the pending or running state. The task'sState 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.

example

cancel([j](#mw%5F0bc5a929-2e50-471b-9987-cdd8fdf51a93)) stops the job object,j, that is pending, queued, or running. The job'sState 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 a MATLABĀ® Job Scheduler, 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.

Examples

collapse all

Cancel Tasks

Cancel a task. Note afterward the task's State andError properties.

c = parcluster(); job1 = createJob(c); t = createTask(job1, @rand, 1, {3,3}); cancel(t) t

Task with properties:

               ID: 1
            State: finished
         Function: @rand
           Parent: Job 1
    StartDateTime: 
 RunningDuration: 0 days 0h 0m 0s

            Error: The task was cancelled by user "mylogin" on machine "myhost.mydomain.com".
         Warnings: none

Version History

Introduced before R2006a