Created
February 25, 2014 00:45
-
-
Save PeloNZ/9200406 to your computer and use it in GitHub Desktop.
kill active postgres connections and drop the requested db
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
#!/bin/bash | |
# kill active pg connections and drop the requested db | |
DB=$1 | |
psql -ec "SELECT pg_terminate_backend(pg_stat_activity.procpid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$DB' AND procpid <> pg_backend_pid();" postgres | |
dropdb $DB | |
exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment