bash 如何在 pg_dump 中传递日志文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23133659/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 10:14:41  来源:igfitidea点击:

How to pass log file in pg_dump

bashpostgresqlunix

提问by Java_Alert

I am using this command to export.

我正在使用此命令导出。

export PGPASSWOD=${PASSWORD}

    pg_dump –i –b -o -host=${HOST} -port=5444 -username=${USERNAME} -format=c -schema=${SCHEMA} --file=${SCHEMA}_${DATE}.dmp ${HOST} 

Just want to know how can i include the log file in it so that i can get logs also.

只是想知道如何在其中包含日志文件,以便我也可以获取日志。

回答by harmic

I assume you mean you want to capture any errors, notifications, etc that are output by pg_dump in a file.

我假设您的意思是要捕获 pg_dump 在文件中输出的任何错误、通知等。

There is no specific option for this, but pg_dump will write these to STDERR, so you can easily capture them like this:

对此没有特定选项,但 pg_dump 会将这些写入 STDERR,因此您可以像这样轻松捕获它们:

pg_dump –i –b -o ...other options ... 2> mylogfile.log

In a shell, 2>redirects STDERR to the given file.

在 shell 中,2>将 STDERR 重定向到给定的文件。

This advice is good for nearly any command line tool you are likely to find on a *nix system.

这个建议几乎适用于您可能在 *nix 系统上找到的任何命令行工具。