In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
How to use the awk batch kill process command, in view of this problem, this article introduces the corresponding analysis and answer in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.
In the process of system operation and maintenance, sometimes when you need to kill a certain type of process, how to kill these processes in batches, using the awk command is a good choice.
Ps-ef | grep aaa | grep-v grep | awk'{print "kill-9" $2}'| sh
1.ps-ef | grep aaa | grep-v grep this is a familiar command, so I won't say much here, that is, a process that contains the aaa keyword in the process name of the process running on the current system.
two。 The latter part is the awk command. The general format of the awk command is: awk 'pattern {action}'.
Print is the print, kill-9 is the command that forces the process to stop, and $2 is what is shown in the second column with the result of the ps-ef command.
Here is a simple example:
[PD_APP1:/home/tbcs] # ps-ef | grep boco | grep-v grep
Root 9884 9883 0 17:10:01? 0:00 sendmail-oem-oi-froot boco
Root 9883 9880 0 17:10:01? 0:00 / usr/bin/mail boco
Boco 11112 1 0 Dec 24? 0:00. / boco_appmaster-d / home/boco/agent
Boco 11126 11125 61 Dec 24? 52:59. / boco_hostagent-I socket-l
Boco 11125 11112 37 Dec 24? 43:25. / boco_appmaster-d / home/boco/agent
Boco 9811 11113 0 17:09:31? 0:00 sleep 60
Boco 11113 1 0 Dec 24? 0:23 / bin/sh. / boco_monitor.sh
[PD_APP1:/home/tbcs] # ps-ef | grep boco | grep-v grep | awk'{print "kill-9" $2}'
Kill-9 9884
Kill-9 9883
Kill-9 11112
Kill-9 11126
Kill-9 11125
Kill-9 9811
Kill-9 11113
As you can see, ps-ef | grep boco | grep-v grep lists the processes running on the current host that contain the boco keyword
Ps-ef | grep boco | grep-v grep | awk'{print "kill-9" $2} 'lists the commands to kill these processes and prints them on the screen.
Add | sh after ps-ef | grep boco | grep-v grep | awk'{print "kill-9" $2}', then execute these commands, killing the processes.
This is the answer to the command question on how to use the awk batch killing process. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.