I could close specified apps like

$ killall "PDF Expert"
$ killall "Google Chrome"

The active processes could be check with command top

enter image description here

How could I kill all the process with codes like

for process in processes; do
       killall "$process"
  • 3
    The shutdown comnand ... – Solar Mike May 17 '18 at 13:29
  • have you considered using the PID? Since its a number it may be easier to use. You could maybe kill all between 73833 thru 83833 for example. – Natsfan May 17 '18 at 19:43
  • If you kill all active processes your Mac will crash. So what do you want to accomplish? – nohillside May 18 '18 at 8:04

There is a much more powerful command on the shell to kill processes. Have a look at the "pkill" command syntax:

    PKILL(1)                  BSD General Commands Manual                 PKILL(1)

     pgrep, pkill -- find or signal processes by name

     pgrep [-Lafilnoqvx] [-F pidfile] [-G gid] [-P ppid] [-U uid] [-d delim] [-g pgrp] [-t tty]
           [-u euid] pattern ...
     pkill [-signal] [-ILafilnovx] [-F pidfile] [-G gid] [-P ppid] [-U uid] [-g pgrp] [-t tty] [-u euid]
           pattern ...

My personal favourite for killing specific processes is

pkill -9 -u <user> -f <Match against full argument lists.>

So if I want to kill all processes from the Razer Synapse software, because the update agent sometimes has hung up and the Razer Synapse Tool does not start, I type

Tatooine-2257:~ mallert$ ps -eaf | grep Razer
  503 87700     1   0 12:46pm ??        15:46.40 /Library/Application Support/Razer/RzUpdater.app/Contents/MacOS/RzUpdater
  503 87749     1   0 12:46pm ??        30:42.02 /Library/Application Support/Razer/RzDeviceEngine.app/Contents/MacOS/RzDeviceEngine
  503 92697     1   0  2:04pm ??         0:13.17 /Applications/Razer Synapse.app/Contents/MacOS/Razer Synapse
  503 42720  1007   0 10:02pm ttys006    0:00.00 grep Razer
Tatooine-2257:~ mallert$ pkill -9 -f Razer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .