Skip to content

Instantly share code, notes, and snippets.

@rwcitek
Last active August 29, 2015 14:11
Show Gist options
  • Save rwcitek/21b1229e21ae795ddfca to your computer and use it in GitHub Desktop.
Save rwcitek/21b1229e21ae795ddfca to your computer and use it in GitHub Desktop.
Generates a list of RPM packages for listening services that may require a restart with an upgrade.
#!/bin/bash
# Generates a list of RPM packages for listening services that may result in services being restarted during a upgrade.
# These probably should not be upgraded automatically in a production environment.
netstat -plntu |
grep -o '[0-9]*/' |
tr -d / |
sort -u |
xargs -r -i stat -c "%N" /proc/{}/exe |
tr -d "\`'" |
cut -d" " -f3 |
xargs -r rpm -q --qf '%{NAME}\n' -f |
grep -v 'not owned' |
sort |
uniq
# To view the start times (and other info) of listening processes:
netstat -plntu |
grep -o '[0-9]*/' |
tr -d / |
xargs -r ps u -p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment