Skip to content

Instantly share code, notes, and snippets.

@11808s8
Created December 30, 2019 04:07
Show Gist options
  • Select an option

  • Save 11808s8/65ab2b5a1afcfbf6b3eb452d5e21e818 to your computer and use it in GitHub Desktop.

Select an option

Save 11808s8/65ab2b5a1afcfbf6b3eb452d5e21e818 to your computer and use it in GitHub Desktop.
Script that searches for the PostgreSQL server running at port 5432, grabs it's PID and kills it's process with the discovered PID.
#!/bin/bash
sudo kill $(sudo ss -lptn 'sport = :5432' | grep -o 'pid=[0-9]\+' | grep -o '[0-9]\+')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment