0

Using macOS sierra, i am searching for a command with which i can close/kill all opened terminal windows (processes). Also it should killing all processes opened by this terminals... Why pkill Terminal does not work?

2 Answers 2

4

Short answer:

pkill -a Terminal

Slightly longer answer:

The above command search all processes which have the name "Terminal" in them and kill them. This will kill the shell process (e.g. bash) and any processes in the same process tree (commands run under the control of the shell). It probably won't kill GUI applications since they often double fork. Since these are no longer associated with the Terminal process, it's not possible to figure out which ones were originally launched by the terminal.

Also, to find the process without killing it, run:

pgrep -a Terminal
4
  • Why pkill Terminal does not work?
    – illdo
    Commented Apr 30, 2018 at 12:19
  • Sorry, it does. Answer has been edited to correct my mistake
    – mnewt
    Commented May 1, 2018 at 20:57
  • I have tried pkill -a Terminal - yes it closes all terminals. But when i open terminal again- all previously closed windows open again =(
    – illdo
    Commented May 6, 2018 at 14:40
  • I see. This is the best I can think of at the moment: tell application "Terminal" close every window quit end tell But it prompts you to confirm the closing of each tab. I haven't figured out how to bypass that via script.
    – mnewt
    Commented May 8, 2018 at 15:21
0

How about cmd+q? It closes the application and all windows of it. If you can send keyboard command.

  • It will ask you if you want to terminate all processes before closing all terminals.
  • It does not re-open all closed terminals on next launch.
2
  • tried this, but it does not kill processes, that was running in terminals. I have nodejs processes in terminals - terminals closed with cmd+q, but if i run terminal again -pgrep node shows this proceses still running
    – illdo
    Commented May 22, 2018 at 17:00
  • sorry to hear that :( it worked for me though, will leave answer for other googlers Commented May 24, 2018 at 19:33

You must log in to answer this question.

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