Re: idle users

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: paulo matadr <saddoness(at)yahoo(dot)com(dot)br>
Cc: GENERAL <pgsql-general(at)postgresql(dot)org>
Subject: Re: idle users
Date: 2009-03-06 02:57:47
Message-ID: dcc563d10903051857n1bdb50e0q526504b29cf9d2ec@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Mar 5, 2009 at 5:50 AM, paulo matadr <saddoness(at)yahoo(dot)com(dot)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.

In response to

  • idle users at 2009-03-05 12:50:09 from paulo matadr

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2009-03-06 03:35:28 Re: converting older databases
Previous Message Scott Marlowe 2009-03-06 02:48:13 Re: idle users