简体   繁体   English

如果存档有SQL错误,Crontab跳过pg_restore

[英]Crontab skipping pg_restore if archive has sql errors

I have a strange problem with cron which is skipping pg_restore command (Postgres Restore) in the script file and not reporting any errors in the log file even if stderr is enabled. 我对cron有一个奇怪的问题,那就是在脚本文件中跳过pg_restore命令(Postgres Restore),即使启用了stderr也不会在日志文件中报告任何错误。 Could any one help what I am doing wrong? 有人可以帮我做错什么吗?

Update: Added Distribution Info and Cron, 更新:添加了发行信息和Cron,

I am using CentOS release 5.4 (Final) distribution with 64 bit package and my cron job is, 我正在使用带有64位软件包的CentOS 5.4版(最终版)发行版,我的cron工作是,

51 14 * * * /opt/scripts/test.sh 2>&1  >> /opt/logs/test.txt

Note: This is happening if backup(*.tar) archive has any errors but restores if I run the script manually. 注意:如果backup(*。tar)归档文件有任何错误,但是如果我手动运行脚本则可以恢复,则会发生这种情况。

Thanks, 谢谢,
Karthik 卡尔提克

The odds are that you must specify the absolute, full path to the pg_restore command. 很有可能您必须指定pg_restore命令的绝对完整路径。

Since you don't seem to show your script, I cannot actually see that you forgot to. 由于您似乎没有显示脚本,所以我实际上看不到您忘记了。

This is a FAQ item since cron jobs run in a reduced environment and the PATH variable can be set to other things (or even be unset) 这是一个常见问题,因为cron作业在简化的环境中运行,并且PATH变量可以设置为其他值(甚至可以不设置)

问题出在postgres版本和已安装的CentOS上,因为我使用外部存储库下载了最新版本的postgres,并了解始终最好只从同一存储库下载由centos团队支持和验证的postgres版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM