Re: idle users - Mailing list pgsql-general

From Scott Marlowe
Subject Re: idle users
Date
Msg-id dcc563d10903051857n1bdb50e0q526504b29cf9d2ec@mail.gmail.com
Whole thread Raw
In response to idle users  (paulo matadr <saddoness@yahoo.com.br>)
List pgsql-general
On Thu, Mar 5, 2009 at 5:50 AM, paulo matadr <saddoness@yahoo.com.br> wrote:
> I need to procedure to kill users in idle,anybody have this made?
> thanks
> Paulo Moraes

Here's a really primitive bash script to kill off all idle
connections.  Run it as postgres:

#!/bin/bash
for i in `psql -U postgres -t -c "select procpid from pg_stat_activity
where current_query like '%<IDLE> in transaction%' and current_query
not ilike '%from pg_stat_activity%';"` ;do
    echo $i;
    kill $i;
done;

Note that the psql -U line shouldn't be wrapped, unwrap it if you
can't see it in its original glory.

I make no promises that this thing won't eat your machine or anything
else.  works on my laptop.

pgsql-general by date:

Previous
From: Lubomir Petrov
Date:
Subject: Re: Hiding row counts in psql
Next
From: Scott Marlowe
Date:
Subject: Re: converting older databases