Skip to main content
1 of 2

PostgreSQL - psql \watch command - how to interrupt

The output of SELECT version();

------------------------------------------------------------
 PostgreSQL 14.1, compiled by Visual C++ build 1914, 64-bit
(1 row)

and it's a binary distribution from EnterpriseDB. Might also be using 12 or 13, but I don't imagine it makes much of a difference.

I'm running Windows 10, but I will also be running Linux - any differences to be noted would be appreciated.

The psql \watch command is great. If I run

SELECT 1 AS "Waste of my time"
\watch 1;

then the output is:

27/11/2021 07:06:41 (every 1s)

 Waste of my time
------------------
                1
(1 row)

27/11/2021 07:06:42 (every 1s)

 Waste of my time
------------------
                1
(1 row)

&c....

which is great. But, if I try to stop it by typing q or Ctrl-D or Ctrl-Z - no joy.

The only thing that works is Ctrl-C but that has the problem of stopping my server which is a PITA.

How can I interrupt the \watch process in a way that just returns me to the psql prompt?