The Postgres REPL psql in includes a
\watch command that repeatedly executes a command every
n seconds. Here’s the official description:
\watch [ seconds ] Repeatedly execute the current query buffer (like \g) until interrupted or the query fails. Wait the specified number of seconds (default 2) between executions.
It executes the current query buffer, which you can print with
tilex_dev=# \p select title from posts order by inserted_at desc limit 1;
\watch and tail your query result as it changes:
tilex_dev=# \watch Sun Jul 29 17:06:13 2018 (every 2s) title ---------------------- Psql Watch (1 row) Time: 2.175 ms