Reputation: 1175
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
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
Reputation: 1912
The output of the 'yarn application -list' contains the following information of yarn applications:
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
Reputation: 11593
yarn application -list
This will give you a list of the applications, with application ID, running on yarn.
Upvotes: 5