Partilhar via


Force Cancel a Job or Task

A cluster administrator or a job owner can force cancel a running job or task. When a job is force canceled, the Node Release is skipped and the tasks in the job are force canceled. When a task is force canceled, the task and its sub-tasks skip the grace period and are stopped immediately.

You cannot force cancel jobs or tasks in HPC Cluster Manager. The following sections show how to force cancel jobs or tasks using HPC PowerShell or a command prompt window.

Note

To complete this procedure, you must be the job owner or a cluster administrator.

Force cancel a job

Force canceling a job stops the job immediately. The tasks in the job do not use the Task Cancel Grace Period, and the Node Release task does not run.

To force cancel a job, use one of the following methods. Include the –force parameter, and specify the ID of your job.

  • In HPC PowerShell use the following cmdlet: Stop-HpcJob <yourJobID> -force

  • At a command prompt use the following command: job cancel <yourJobID> /force

Force cancel a task

Force canceling a task stops the task and its sub-tasks immediately and does not use the Task Cancel Grace Period.

To force cancel a task, use one of the following methods. Include the –force parameter and specify the ID of your job and task, and optionally, the sub-task.

  • In HPC PowerShell, use the following cmdlet: Stop-HpcTask –JobId <yourJobID> -TaskID <yourTaskID> [-subTaskID <yourSubTaskID>] -force

  • At a command prompt, use the following command: task cancel <yourJobID>.<yourTaskID>[.<yourSubTask>] /force

Additional considerations

  • Tasks that are canceled while they are running are marked as Failed. Tasks that are canceled before they start are marked as Canceled.

  • When a job is canceled, Running tasks are marked as Failed, and Queued tasks remain in the Queued state.

  • In HPC Pack, canceled tasks can make use of the Task Cancel Grace Period to save state information and clean up before exiting. The default grace period is 15 seconds. To use the grace period, the application must process the CTRL_BREAK event. If the application does not process the event, the task exits immediately. For a service to use the grace period, it must process the ServiceContext.OnExiting event. Tasks that are force canceled skip the grace period.

Additional references