You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Starting Situation

  • A number of tasks might be running in JobScheduler that should immediately be killed.
  • This could happen
    • due to some misbehaving scripts that cause a large number of job starts.
    • due to a business requirement for an emergeny stop.

Use Cases

Kill all tasks

C:\PS> Get-Task | Stop-Task
  • The Get-Task cmdlet retrieves all running tasks.
  • The list of tasks is piped to the Stop-Task cmdlet.
  • Depending on the system load the killing of tasks might take some seconds. Repeatedly executing the Get-Task cmdlet should prove that no further tasks are running.

Kill tasks for any jobs that are located in a folder

C:\PS> Get-Job /some_folder/some_subfolder | Get-Task | Stop-Task
  • The Get-Job cmdlet retrieves jobs starting from the specified directory. Any subfolders of that directory are included unless the -NoSubfolders parameter is specified.
  • The Get-Task cmdlet retrieves all running tasks for the list of jobs.
  • The list of tasks is piped to the Stop-Task cmdlet.

Kill tasks for any jobs of a job chain

C:\PS> Get-JobChain -JobChain /some_folder/some_job_chain | Get-Job | Get-Task | Stop-Task
  • The Get-JobChain cmdlet retrieves the specified job chain.
  • The Get-Job cmdlet retrieves jobs for the resulting job chain(s).
  • The Get-Task cmdlet retrieves all running tasks for the list of jobs.
  • The list of tasks is piped to the Stop-Task cmdlet.

See also

  • The Stop-Task cmdlet supports a number of actions to kill (sending SIGKILL) and to terminate (sending SIGTERM) signals to processes, For details see How to Terminate Tasks.

 

 

 

  • No labels