Question

I'm writing a cron job to backup a database using pg_dump. I'm looking for a way of redirecting error messages so I can email a backup log file at the end of the process. Is this possible? I can't see anything in the pg_dump documentation that would support this.

Was it helpful?

Solution

You won't find any redirection information in the documentation of _any Unnix based tool because not the tool will redirect the output but the shell which executes that tool will do this. So the usual things work for pg_dump to:

pg_dump .... 2>/tmp/pg_dump.log

For more possibilities you may lookup the section REDIRECTION of the shell using the command

man bash
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top