I'm running Postgres 9.1 (Homebrew installation on Mac OSX) and I'd like to monitor my postgres server more closely.

My question relates to logs. I'd like to get the logs displaying in a terminal pane. Here's what the Postgres docs say about the logs:

"On Unix-like systems, by default, the server's standard output and standard error are sent to pg_ctl's standard output (not standard error). The standard output of pg_ctl should then be redirected to a file or piped to another process such as a log rotating program like rotatelogs; otherwise postgres will write its output to the controlling terminal (from the background) and will not leave the shell's process group. On Windows, by default the server's standard output and standard error are sent to the terminal. These default behaviors can be changed by using -l to append the server's output to a log file. Use of either -l or output redirection is recommended."

So, when I get my postgres server running with the following:

pg_ctl start -D /usr/local/var/postgres

The logs display in the terminal window. When I run:

pg_ctl start -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log

The logs go to my logfile and don't display in terminal.

In short, it would be great if anyone can tell me what command I use after I've directed logs to the file (with the second command) to make the logs also appear at the command line. It helps when I'm developing (in Django) to watch the SQL statements get executed in real time.

  • 1
    If I understand you correctly, you should have a look at tee. Commented Aug 4, 2012 at 7:55

2 Answers 2


Just use tail -f /path/to/log and you'll be able to see the log contents in a terminal as well. You can use a terminal tool that can "monitor for activity" if you'd like to be notified when something happens.

A more complex solution would be to set PostgreSQL to log to rsyslog, and set rsyslog to log to a tty as well as a file


the "-a" in the "tee" command is for appeding text to the log file.

pg_ctl start -D /usr/local/var/postgres | tee -a /usr/local/var/postgres/server.log

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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