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.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With