2

My OS is RHEL5.

I want to direct the console output produced by the following database command to a log/file.

psql mydb mydbuser -c "VACUUM ANALYZE VERBOSE"

I've tried out the following commands and is not working as expected. But it is printing output to the terminal console instead.

psql mydb mydbuser -c "VACUUM ANALYZE VERBOSE" > vacuum.log
psql mydb mydbuser -c "VACUUM ANALYZE VERBOSE" | tee vacuum.log

Here, in this case, is not the output produced by this command a standard input/output/error?

NOTE: psql is a terminal-based front-end to PostgreSQL. It enables you to type in queries interactively, issue them to PostgreSQL, and see the query results.

3

Redirect stderr as well.

psql mydb mydbuser -c "VACUUM ANALYZE VERBOSE" &> vacuum.log
| improve this answer | |

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.