Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kill yarn application by Application-Name

Tags:

hadoop-yarn

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

like image 629
Amine CHERIFI Avatar asked Dec 25 '22 06:12

Amine CHERIFI


1 Answers

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

like image 195
Lakshman Battini Avatar answered Dec 28 '22 08:12

Lakshman Battini