Take the 2-minute tour ×

I was using interactive psql to run a reindex on one of our databases. Unfortunately, the ssh connection dropped while the reindex was still running and I had foolishly not put psql inside a screen window (I didn't realize how long it took!)

Once I was able to login again to the machine, I ran

ps aux | grep REINDEX 

and the output seemed to indicate that the reindex was still running:

postgres  6180 99.9  0.0 774960  4804 ?        Rs   Jun27 3022:02 postgres: postgres my_db_name [local] REINDEX 

What is the expected behaviour of postgres in this situation? Will it continue to run the reindex to completion?

Also, is there any way to re-connect to psql in such a way that I can continue seeing the in-progress output from the reindex?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

The REINDEX may get aborted as it tries to send feedback to a psql that doesn't exist anymore, and this finally propagates through as a "client disconnected". Or, if the psql does still exist, it will finally die when its tty and sshd buffers overfill... this will presumably make it take longer, though.

Reconnecting to see the output of that command isn't really possible, no.

share|improve this answer
add comment

It's been my experience that things like these die as soon as your shell is terminated by idle activity.

This is one of the circumstances where you should be using something like GNU Screen. With GNU Screen you log into your server, type screen, and then begin your work. You can spawn additional terminals inside that screen session with Ctrl+a c , and cycle between them with Ctrl+a n and Ctrl+a p. To disconnect from the GNU Screen you can type Ctrl+a d. To reconnect you can log in and run screen -r .

A Howto from Kuro5hin is available here: http://www.kuro5hin.org/story/2004/3/9/16838/14935

share|improve this answer
Yes, I generally use screen for long-running processes; in this case I didn't realize how long the reindex would take. Whoops! –  eulerz Jun 30 '11 at 17:37
add comment

Your Answer


