[LINUX] How to kill processes in bulk

I have a lot of chromedriver processes, It is very inefficient to kill with the kill command in order using the process number.

$ ps aux|grep chromedriver
yusaku            8013   0.0  0.1  4360484  12024 s001  S     1:01PM   0:00.22 /Users/yusaku/chromedriver --port=53472
yusaku            2932   0.0  0.1  4360484  11992 s001  S    12:25AM   0:00.25 /Users/yusaku/chromedriver --port=64392
yusaku            2880   0.0  0.1  4360484  11988 s001  S    12:25AM   0:00.26 /Users/yusaku/chromedriver --port=64302
yusaku            2512   0.0  0.1  4360484  12256 s001  S    12:07AM   0:00.28 /Users/yusaku/chromedriver --port=63331
yusaku           99432   0.0  0.1  4360620  12268 s001  S     8:08PM   0:00.36 /Users/yusaku/chromedriver --port=56561
yusaku           99261   0.0  0.1  4360620  12252 s001  S     7:59PM   0:00.48 /Users/yusaku/chromedriver --port=56221
yusaku           98284   0.0  0.1 4360620 12236 s001 S Sat 05PM 0:00.60 /Users/yusaku/chromedriver --port=55684
yusaku           98202   0.0  0.1 4360620 12240 s001 S Sat 05PM 0:00.43 /Users/yusaku/chromedriver --port=55487
yusaku           98120   0.0  0.1 4360620 12256 s001 S Sat 05PM 0:00.44 /Users/yusaku/chromedriver --port=55307
yusaku           98031   0.0  0.1 4360620 12320 s001 S Sat 05PM 0:00.33 /Users/yusaku/chromedriver --port=55113
yusaku           97976   0.0  0.1 4360484 12268 s001 S Sat 05PM 0:00.35 /Users/yusaku/chromedriver --port=55082
yusaku           97891   0.0  0.1 4360620 12540 s001 S Sat 05PM 0:00.51 /Users/yusaku/chromedriver --port=54923
yusaku           97807   0.0  0.1 4360620 12464 s001 S Sat 05PM 0:00.44 /Users/yusaku/chromedriver --port=54755
yusaku           97014   0.0  0.1 4360484 12004 s001 S Sat 04PM 0:00.34 /Users/yusaku/chromedriver --port=53365
yusaku           96928   0.0  0.1 4360484 11992 s001 S Sat 04PM 0:00.31 /Users/yusaku/chromedriver --port=53308
yusaku           96873   0.0  0.1 4360484 12000 s001 S Sat 04PM 0:00.31 /Users/yusaku/chromedriver --port=53169
yusaku           96811   0.0  0.1 4360484 12016 s001 S Sat 04PM 0:00.34 /Users/yusaku/chromedriver --port=53027
yusaku           95623   0.0  0.1  4360484  11984   ??S Sat 03 PM 0:00.32 /Users/yusaku/chromedriver --port=52319
yusaku           95584   0.0  0.1  4360484  12012   ??S Sat 03 PM 0:00.32 /Users/yusaku/chromedriver --port=52297
yusaku           95533   0.0  0.1  4360484  12012   ??S Sat 03 PM 0:00.34 /Users/yusaku/chromedriver --port=52151
yusaku           95495   0.0  0.1  4360484  12000   ??S Sat 03 PM 0:00.33 /Users/yusaku/chromedriver --port=52133
yusaku           95445   0.0  0.1  4360484  11988   ??S Sat 03 PM 0:00.32 /Users/yusaku/chromedriver --port=51998
yusaku           95405   0.0  0.1  4360484  12000   ??S Sat 03 PM 0:00.31 /Users/yusaku/chromedriver --port=51979
yusaku           95340   0.0  0.1  4360484  11976   ??S Sat 03 PM 0:00.32 /Users/yusaku/chromedriver --port=51817
yusaku           95280   0.0  0.1  4360484  11984   ??S Sat 03 PM 0:00.35 /Users/yusaku/chromedriver --port=51679
yusaku           95214   0.0  0.1  4360484  12004   ??S Sat 03 PM 0:00.31 /Users/yusaku/chromedriver --port=51621
yusaku           95160   0.0  0.1  4360484  11996   ??S Sat 03 PM 0:00.31 /Users/yusaku/chromedriver --port=51589
yusaku           95068   0.0  0.1  4360484  11984   ??S Sat 03 PM 0:00.31 /Users/yusaku/chromedriver --port=51404
yusaku           95026   0.0  0.1  4360484  12008   ??S Sat 03 PM 0:00.31 /Users/yusaku/chromedriver --port=51385
yusaku           94964   0.0  0.1  4360484  11972   ??S Sat 03 PM 0:00.32 /Users/yusaku/chromedriver --port=51310
yusaku           94891   0.0  0.1  4360484  12008   ??S Sat 03 PM 0:00.31 /Users/yusaku/chromedriver --port=51265
yusaku           94795   0.0  0.1  4368688  12228   ??S Sat 03 PM 0:00.32 /Users/yusaku/chromedriver --port=50551
yusaku           94743   0.0  0.1  4360484  12280   ??S Sat 03 PM 0:00.33 /Users/yusaku/chromedriver --port=50411
yusaku           94627   0.0  0.1  4360484  12272   ??S Sat 03 PM 0:00.32 /Users/yusaku/chromedriver --port=50249
yusaku           94565   0.0  0.1  4360484  12284   ??S Sat 03 PM 0:00.33 /Users/yusaku/chromedriver --port=50088
yusaku           94508   0.0  0.1  4360484  12260   ??S Sat 03 PM 0:00.34 /Users/yusaku/chromedriver --port=49947
yusaku           94016   0.0  0.1  4360484  12244   ??S Sat 03 PM 0:00.32 /Users/yusaku/chromedriver --port=49324
yusaku           93963   0.0  0.1  4360484  12248   ??S Sat 03 PM 0:00.33 /Users/yusaku/chromedriver --port=49179
yusaku           93910   0.0  0.1  4360484  12204   ??S Sat 03 PM 0:00.32 /Users/yusaku/chromedriver --port=65531
yusaku           93859   0.0  0.1  4360484  12232   ??S Sat 03 PM 0:00.37 /Users/yusaku/chromedriver --port=65390
yusaku           93808   0.0  0.1  4360484  12220   ??S Sat 03 PM 0:00.37 /Users/yusaku/chromedriver --port=65259
yusaku           93758   0.0  0.1  4360484  12212   ??S Sat 03 PM 0:00.32 /Users/yusaku/chromedriver --port=65231
yusaku           93607   0.0  0.1  4360484  12236   ??S Sat 03 PM 0:00.36 /Users/yusaku/chromedriver --port=64962
yusaku           11837   0.0  0.0  4277992   1008 s001  S+    7:36PM   0:00.00 grep chromedriver
yusaku           11749   0.0  0.2  4360484  13808 s001  S     7:30PM   0:00.06 /Users/yusaku/chromedriver --port=58743
yusaku           11636   0.0  0.2  4360484  13836 s001  S     7:28PM   0:00.07 /Users/yusaku/chromedriver --port=58678

How to kill in bulk

You can kill them all at once using pgrep and xargs.

$ pgrep chromedriver| xargs kill -9
$
$ ps aux|grep chromedriver
yusaku           11934   0.0  0.0  4267752   1008 s001  S+    7:48PM   0:00.01 grep chromedriver

Recommended Posts

How to kill processes in bulk
How to develop in Python
How to run tests in bulk with Python unittest
[Python] How to do PCA in Python
How to handle session in SQLAlchemy
How to use classes in Theano
How to write soberly in pandas
How to collect images in Python
How to update Spyder in Anaconda
How to use SQLite in Python
How to convert 0.5 to 1056964608 in one shot
How to reflect CSS in Django
How to use Mysql in python
How to wrap C in Python
How to use ChemSpider in Python
How to use PubChem in Python
How to run TensorFlow 1.0 code in 2.0
How to handle Japanese in Python
How to log in to Docker + NGINX
How to call PyTorch in Julia
How to use calculated columns in CASTable
[Introduction to Python] How to use class in Python?
How to suppress display error in matplotlib
How to access environment variables in Python
How to dynamically define variables in Python
How to do R chartr () in Python
How to convert csv to tsv in CLI
How to delete expired sessions in Django
[Itertools.permutations] How to put permutations in Python
How to implement nested serializer in drf-flex-fields
How to work with BigQuery in Python
How to execute commands in jupyter notebook
How to do'git fetch --tags' in GitPython
How to get a stacktrace in python
How to display multiplication table in python
How to reassign index in pandas dataframe
How to use Anaconda interpreter in PyCharm
How to specify non-check target in Flake8
How to handle consecutive values in MySQL
How to switch python versions in cloud9
How to adjust image contrast in Python
How to use __slots__ in Python class
How to dynamically zero pad in Python
How to do Server-Sent Events in Django
How to use regular expressions in Python
How to implement Scroll View in pythonista 1
How to convert DateTimeField format in Django
How to use Map in Android ViewPager
How to display Hello world in python
How to read CSV files in Pandas
How to change editor color in PyCharm
How to write this process in Perl?
How to use is and == in Python
How to write Ruby to_s in Python
How to view images in Django's Admin
How to draw OpenCV images in Pygame
How to revive cells in iPython notebook
How to move BufferImageStim object in PsychoPy
How to deal with memory leaks in matplotlib.pyplot
How to use the C library in Python
How to receive command line arguments in Python