Terminate all query on postgresql with one command line

Please don’t use this if you do not know what exactly gonna happen.

format :
psql -U{USERNAME} -h{HOSTNAME} {DATABASE_NAME} -c "select pid from pg_stat_activity" -t | xargs -n1 -I {} psql -c "SELECT pg_terminate_backend({})"

change the variable with that suits to your configuration, i put sampel below

sample :
psql -Ugoogleadmin -hgoogle_com google_production_db -c "select pid from pg_stat_activity" -t | xargs -n1 -I {} psql -c "SELECT pg_terminate_backend({})"

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s