Stop-HpcJob

Stop-HpcJob

Cancels one or more specified jobs.

Syntax

Parameter Set: id
Stop-HpcJob [-Id] <Int32[]> [-Force] [-Message <String> ] [-Scheduler <String> ] [-State <String> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: job
Stop-HpcJob -Job <HpcJob[]> [-Force] [-Message <String> ] [-Scheduler <String> ] [-State <String> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Detailed Description

Cancels one or more specified jobs. You can specify the job by using the identifiers or the HpcJob objects for the jobs. You can specify that you want to cancel the job immediately, without using the grace period for task cancelation and without running the node release task. You can also specify that the state of the job after it is canceled should be Finished instead of Canceled, and you can specify an error message to explain why you canceled the jobs.

When you cancel a job, the job scheduler removes the job from the job queue if the job is waiting to run. If the job is running, the scheduler stops the tasks that are running, and it frees the resources that those tasks were using so that they can be allocated to another job.

Only an administrator or the owner of the job can cancel a job.

Parameters

-Force

Stops the job immediately, without using the grace period for task cancelation and without running the node release task, if the job contains one.

This parameter was introduced in Windows HPC Server 2008 R2. It is not supported in previous versions.

Aliases

none

Required?

false

Position?

named

Default Value

not applicable

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Id<Int32[]>

Specifies a list of identifiers for the jobs that you want to cancel. Specify the Id parameter or the Job parameter, but not both.

Aliases

none

Required?

true

Position?

1

Default Value

no default

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Job<HpcJob[]>

Specifies a list of HpcJob objects that represent the jobs that you want to cancel.

Aliases

none

Required?

true

Position?

named

Default Value

no default

Accept Pipeline Input?

True (ByValue)

Accept Wildcard Characters?

false

-Message<String>

Specifies an error message to provide to the user that explains why you canceled the job.

Aliases

none

Required?

false

Position?

named

Default Value

no default

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Scheduler<String>

Specifies the host name or IP address of the head node for the cluster to which you submitted the job. The value must be a valid computer name or IP address. If you do not specify the Scheduler parameter, this cmdlet uses the scheduler on the head node that the CCP_SCHEDULER environment variable specifies. To set this environment variable, run the following cmdlet:

Set-Content Env:CCP_SCHEDULER <head_node_name>

Aliases

none

Required?

false

Position?

named

Default Value

%CCP_SCHEDULER%

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-State<String>

Specifies the state of the job after it is canceled. The only valid value is Finished. If you do not specify the State parameter, the job has a state of Canceled after it is canceled. Use this parameter when you want to end a job that has the RunUntilCanceled property set to true, and want to set the state of the job to Finished because you have an alternate way to check that the job finished.

This parameter was introduced in Windows HPC Server 2008 R2. It is not supported in previous versions.

Aliases

none

Required?

false

Position?

named

Default Value

no default

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Confirm

Prompts you for confirmation before executing the command.

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WhatIf

Describes what would happen if you executed the command without actually executing the command.

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • One or more HpcJob objects

Outputs

The output type is the type of the objects that the cmdlet emits.

  • None

Notes

  • To cancel a job, the state of the job must be Configuring, Submitted, Validating, Queued, or Running. If the job is running tasks when you cancel the job, the tasks are stopped and marked as failed.

    If you queue the job again, the status of the tasks in the job depends on the state of the tasks when you can canceled the job. Tasks that were finished when you canceled the job stay finished. Tasks that were explicitly canceled before they ran and that are currently in the canceled state stay canceled. All other tasks are queued, including those that failed.

  • The built-in ConfirmImpact setting for this cmdlet is Medium. If this ConfirmImpact setting is equal to or higher than the value of the $ConfirmPreference variable for your environment, the cmdlet prompts for confirmation unless you specify –Confirm:$false. If this ConfirmImpact setting is lower than the value of the $ConfirmPreference variable for your environment, the cmdlet does not prompt for confirmation unless you specify –Confirm or –Confirm:$true.

Examples

EXAMPLE 1

Cancels the job with an identifier of 45 and provides the user with a cancellation message that explains that you canceled the job to make room for a different job to run.

PS C:\>Stop-HpcJob -Id 45 -Message "Clearing space for Job 51, which needs to run immediately."

EXAMPLE 2

Cancels the job with an identifier of 39 immediately, without using the grace period for task cancelation and without running the node release task.

PS C:\>Stop-HpcJob -Id 39 -Force

EXAMPLE 3

Creates a new job with the RunUntilCanceled property set to true, adds a task to the job, submits the job to the HPC cluster, and then cancels the job so that it has a state of Finished.

PS C:\>$job = New-HpcJob -RunUntilCanceled $true -NumCores "1-3"$job | Add-HpcTask -Command "echo Hello World!"$job | Submit-HpcJob$job | Stop-HpcJob -State Finished

Get-HpcJob

Submit-HpcJob