Skip to content

Instantly share code, notes, and snippets.

@zertrin
Created February 14, 2015 00:40
Show Gist options
  • Save zertrin/28c2d8815785a525293f to your computer and use it in GitHub Desktop.
Save zertrin/28c2d8815785a525293f to your computer and use it in GitHub Desktop.
Find obsolete libs used by processes
function find-obsolete() {
local pid cmd file
for pid in $(\grep '(deleted)' /proc/*/maps | \grep -v '/dev/zero' | cut -d/ -f 3 | sort -un); do
cmd=$(ps -o comm -p $pid | tail -n 1)
for file in $(\grep '(deleted)' /proc/$pid/maps | \grep -v '/dev/zero' | awk '{print $6}' | sort -u); do
echo "$pid $cmd $file"
done
done | column -t
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment