Amine CHERIFI
Amine CHERIFI

Reputation: 1175

Kill yarn application by Application-Name

I want to create a cron to kill a yarn application (Spark) by it application name. But i found thant yarn application -kill needs an application ID. Is there a solution to kill it by application name, or to get the application ID using the application name.

Thank you

Upvotes: 5

Views: 7335

Answers (3)

Saeid BK
Saeid BK

Reputation: 329

The same answer as others but with using xargs

yarn application -list | awk '$2 == "APPLICATION_NAME" { print $1 }' | xargs yarn application -kill

Upvotes: 6

Lakshman Battini
Lakshman Battini

Reputation: 1912

The output of the 'yarn application -list' contains the following information of yarn applications:

  • Application-Id
  • Application-Name
  • Application-Type
  • User
  • Queue
  • State
  • Final-State
  • Progress
  • Tracking-URL

You can list the applications and awk by the required parameter. For ex: to list the applications by 'Application-Name'

yarn application -list | awk '$2 == "APPLICATION_NAME" { print $1 }' > applications_list.txt

Then you can iterate through the file and kill the applications as below:

while read p; do echo $p yarn application -kill $p done <applications_list.txt

Upvotes: 7

David
David

Reputation: 11593

yarn application -list

This will give you a list of the applications, with application ID, running on yarn.

Upvotes: 5

Related Questions