This question already has an answer here:

I like Chrome's feature that lets me restore its pages after it's been closed ungracefully. I use that as a way to save my session (e.g. when just rebooting to install OS updates).

What I've been doing until now:

  • Open Chrome's Task Manager, look for the Browser process and remember the PID.
  • kill the process with that PID (with kill -9 <pid> in Ubuntu and with the task manager in Windows)

I'm looking for a way to do that in just one click, or as few actions as possible. E.g. with a script that I put on my desktop.

I'm looking for a solution both for Windows 7 and Ubuntu Linux.

Note: I know I could use some session-management Chrome extension instead, but I've tried some of those and they don't work exactly like I want, whereas the method described above works exactly like I want, but is a bit too difficult to use.

Note: On both Linux and Windows all my Chrome processes have the name chrome, so I can't differentiate between tab processes and the browser process by name. I'm saying this because I've seen advice to kill the process called google-chrome-stable - I don't have such a process.

Edit: I found this answer on SuperUser which works very well without the need for an killing any processes. I've voted to close my question as a duplicate.

marked as duplicate by Stefan Monov, Dmitry Grigoryev, Pimp Juice IT, G-Man, music2myear Jan 26 '17 at 23:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    Why don't you just download a session saver extension? – DrZoo Dec 14 '16 at 21:39
  • @DrZoo: I haven't yet found an extension that works the way I've described in this question – Stefan Monov Jan 11 '17 at 20:09
  • That’s easy: It’s the Chrome process that doesn’t have a Chrome process as its parent. I’m too lazy to try and write some script now. On Linux you can probably use /proc and on Windows perhaps wmic or something. Or just write a proper program. – Daniel B Jan 11 '17 at 20:13
  • @monov Session Buddy. – DrZoo Jan 11 '17 at 20:43

Simply type:

killall google-chrome-stable

Update after monov's edit:

To kill a tab process: In chromium (I believe in chrome the processes will have similar flags) tab processes are flagged with type=renderer. So in the one-liner below, after listing those processses and extracting PID's, the line number in sed pipe defines the tab number and the nth PID is killed:

ps aux | grep chrome | grep -v grep | grep type=renderer | tr -s " " | cut -d " " -f2 | sed -n 3p | xargs -i kill -9 {}

To kill the xth browser window (the parent process with no flag or additional info after "chrome"). Note that all other processes do not end with "chrome"

ps aux | grep chrome$ | tr -s " " | cut -d " " -f2 | sed -n 3p | xargs -i kill -9 {}

Note: pgrep couldn't return the same answer with end of line ($) regex matching, so I used grep.

If the detailed info in tab process in chrome differs from that in chromium, please let me know.

  • I just added an edit to my question about this. Please see it. – Stefan Monov Dec 14 '16 at 19:52
  • Thanks, but your solutions are for "killing a tab process" and "killing the xth browser window". I want to kill the main browser process instead - the one that owns all the windows and all the tabs. There's never more than one such process. – Stefan Monov Jan 8 '17 at 21:30

Not the answer you're looking for? Browse other questions tagged or ask your own question.