Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get pid of Chrome tab via terminal

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.

like image 405
user137369 Avatar asked Dec 28 '14 18:12

user137369


1 Answers

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.

like image 183
Reilly Grant Avatar answered Oct 16 '22 17:10

Reilly Grant