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 row)

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

 Waste of my time
(1 row)


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?

  • Ctrl-C but that has the problem of stopping my server Can you elaborate? Doesn't stop any "server" for me (pg 14 on Linux). Nov 27, 2021 at 7:21
  • 2
    Why don't you start Postgres as a Windows service? The you don't have a command line window for the server to begin with (btw: the Windows command line in has nothing to do with "DOS") Nov 27, 2021 at 8:02
  • @a_horse_with_no_name I downloaded Sysinternals virtual desktop utility and opened a new psql window there. Ran my SELECT 1 \watch 1; command, let it run for two iterations, hit ^C - just dropped me back to psql prompt. This is excellents. I will write my own answer to own question. DOS - I always call this DOS window - old-fahsioned me! Nov 27, 2021 at 17:44
  • 1
    There is no need to use virtual desktops for this (neither the built-in from Windows 10, nor any external tool) if you install Postgres correctly. Nov 27, 2021 at 18:12

1 Answer 1


This is what I do. The reason it happens in the first place is that I don't like having many windows open on 1 desktop so I start the server running in the background and then start the psql tool in the same window.

So, what I did was download Sysinternals virtual desktop utitly - 4 desktops, just like real operating system!

1 - I start my Postgres server from a window on desktop 4.

2 - then I go to desktop 1 (number not important). What is important is that the window that's running psql tool is NOT the same as window used to start the server.

3 - run the psql tool from desktop 1.

4 - run my command


5 - let the psql tool run watch for a few seconds

6 - hit Ctrl-C. I fall back into psql prompt. I don't lose my connection to the databases and the server doesn't stop.

I hope this can help somebody with the same problem?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.