9

Is it possible to get the pid of a specific Google Chrome tab (like the current one) via the command line? Getting it via AppleScript would be an acceptable solution.

My use case is limiting the CPU usage of a specific tab, so for now my solution to get its pid, since it’ll be the tab with the highest cpu usage, is

ps -Ao %cpu,pid,args | grep 'Google Chrome Helper' | sort --reverse | head -1 | awk '{ print $2 }'

which definitely works. However, were there to be a “cleaner” way, by probing Chrome directly, that’d be preferable.

user137369
  • 5,219
  • 5
  • 31
  • 54
  • I don't know also a way to achieve this and I am interested in a solution. Also with autohotkey you only get the browser PID and not the current tab PID see https://autohotkey.com/board/topic/74322-winget-returns-wrong-pid-for-chromeexe/ – Thierry Dalon Jun 30 '20 at 07:29

2 Answers2

1

This doesn't directly answer your question but you can get the process ID of a tab through the Chrome Task Manager. Open Window > Task Manager.

Reilly Grant
  • 5,590
  • 1
  • 13
  • 23
-2

You can use shift+esc to open google chrome task manager.. and get pid for each tab and process..