Created
December 22, 2016 18:59
-
-
Save xenithorb/1fc581f36a6d8f797a2109362a176456 to your computer and use it in GitHub Desktop.
List listening ports for a cgroup - bashrc style function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find listening ports of a service cgroup | |
# https://www.redpill-linpro.com/sysadvent/2016/12/22/systemd-at-3am.html | |
lsof_listen() { | |
local pids=$( ps -e -o pid,cgroup | awk '$2 ~ /'"$1"'/ { print "-p", $1 }' ) | |
sudo lsof -n -i -a -P ${pids:?ERROR: No PIDs found.} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment