Skip to content

Instantly share code, notes, and snippets.

@amshinde
Last active April 9, 2019 22:41
Show Gist options
  • Save amshinde/60bda307caeb9285eccca2f08e7e27bb to your computer and use it in GitHub Desktop.
Save amshinde/60bda307caeb9285eccca2f08e7e27bb to your computer and use it in GitHub Desktop.
Find processes in namespace

To check if there are any processes are running in a namepace :

$ # Run as root:
$
$ nspath=/tmp/katapod/var/run/netns/cni-4f6eb895-1dfd-cd01-b54e-05ffbef9b0c5
$ inode=$(ls -i $nspath | cut -f1 -d" ")
$ pids=$(find -L /proc/[1-9]*/task/*/ns/net -inum $inode | cut -f3 -d"/" | uniq)
$ ps -p $pids

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment