简体   繁体   English

pgAgent计划的作业在Windows上失败

[英]pgAgent scheduled job failed on Windows

I am trying to set up the step with Batch file path on particular time in pgAgent via pgAdmin. 我正在尝试通过pgAdmin在pgAgent中的特定时间设置具有批处理文件路径的步骤。 But when I run that it is failing and in Step statistics I got this Output 但是当我运行它失败时,在“步骤统计”中我得到了这个输出

C:\\Windows\\system32>C:\\postgresql\\run.bat 'psql' is not recognized as an internal or external command, operable program or batch file. C:\\ Windows \\ system32> C:\\ postgresql \\ run.bat'psql'不被识别为内部或外部命令,可操作程序或批处理文件。

Details: 细节:

Postgresql 9.3.5 on local system account (Current User)
pgAdmin 1.18.1
pgAgent via stack builder with Administrator account (Current User)

in run.bat I have only two statement run.bat中,我只有两个语句

@echo off
psql -h localhost -p 5433 -U postgres -d test -a -f "test.sql"

I have psql in system path variable and able to access it in cmd. 我在系统路径变量中有psql并能够在cmd中访问它。 When I run that bat file manually it is executing without fail. 当我手动运行该bat文件时,它会正常执行。 But when I given the batch file path (C:\\postgresql\\run.bat) in pgAgent jobs it is giving that error in statistics. 但是,当我在pgAgent作业中给出批处理文件路径(C:\\postgresql\\run.bat) ,它在统计信息中给出了该错误。

Is there anything wrong in my configuration? 我的配置有问题吗? Why it is always going to that C:\\Windows\\system32> ? 为什么总是去C:\\Windows\\system32>

Edit: 编辑:

My run.bat file 我的run.bat文件

 @ECHO OFF

SET LBSDatabaseName=Test
SET dbHost=localhost 
SET dbPort=5434 
SET dbUser=postgres 
SET logFile=DbInstall.log 
SET sqlFolder="D:\SOURCECODE\archivescripts"        

"C:\Program Files (x86)\PostgreSQL\9.3\bin\psql.exe" -h "%dbHost%" -p "%dbPort%" -d "%LBSDatabaseName%" -U "%dbUser%" -L "%logFile%" -q -f "%sqlFolder%\Archive.sql"

My Archive.sql 我的Archive.sql

update "Archive".emp set "FirstName"='Srikanth Dyapa';

For example, 例如,

D:\\pgAgent_jobs D:\\ pgAgent_jobs

is the path where psql located. psql所在的路径。

D:\\pgAgent_jobs\\scripts\\test.sql D:\\ pgAgent_jobs \\ scripts \\ test.sql

is the path in which my test.sql placed. 是我的test.sql放置的路径。

D:\\pgAgent_jobs\\scripts\\psqlss.bat D:\\ pgAgent_jobs \\ scripts \\ psqlss.bat

is my bat file to execute test.sql 是我执行test.sql bat文件

so my bat file will be like below 所以我的蝙蝠文件将如下所示

 @echo off

cd /D D:\\pgAgent_jobs

psql -h localhost -p 5432 -U postgres -d db_name -a -f "D:\pgAgent_jobs\scripts\test.sql"

Note : my pg_hba.conf is configured with trust for all hosts that's why am not passing any password in the above psql command 注意:我的pg_hba.conf配置了对所有hoststrust ,这就是为什么在上面的psql命令中不传递任何password的原因

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

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