Search Postgresql Archives

Re: idle users

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 5, 2009 at 5:50 AM, paulo matadr <saddoness@xxxxxxxxxxxx> 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.

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux