quarta-feira, 3 de agosto de 2016

Watching your PostgreSQL database

O comando watch faz com que um segundo comando seja executado em um intervalo fixo:

watch -n 5 "psql -c 'SELECT * FROM pg_stat_activity()' test"

Isso também pode ser feito dentro do console, o psql:

[hs@zenbook ~]$ psql test
psql (9.5.3)
Type "help" for help.

test=# SELECT now();
now
------------------------------
2016-06-02 19:20:42.93694+02
(1 row)

test=# \watch 5
Watch every 5s Thu Jun 2 19:20:48 2016

now
-------------------------------
2016-06-02 19:20:48.430408+02
(1 row)

Watch every 5s Thu Jun 2 19:20:53 2016

now
-------------------------------
2016-06-02 19:20:53.435332+02

(1 row)

Tirei isso do blog http://www.cybertec.at/2016/06/watching-your-postgresql-database/

Nenhum comentário:

Postar um comentário