The
intention of this post is to find out ways to run
pgagent without passing password in its connection string.
Windows:
I have
installed pgagent on windows and configured to run
under Local System account.
Command:-
C:\PostgreSQL\bigsql\pgagent\bin\pgagent.exe
INSTALL pgagent -l 2 -u LocalSystem
hostaddr=127.0.0.1 dbname=postgresdb user=postgres
I have
logged into my windows account; where my profile has
pgpass.conf in %APPDATA%/postgresql/pgpass.conf file.
127.0.0.1:5432:*:postgres:postgres1
Pgagent
is not started and throws error –“The pgagent
service on Local Computer started and then stopped. Some
services stop
automatically if they are not in use by other services or
programs”.
Eventvwr
log messages have these error messages - “Couldn't create the
primary connection (attempt 10): fe_sendauth: no password
supplied”
PGPASSFILE env
variable:
As per
the link- (https://www.postgresql.org/docs/9.6/static/libpq-pgpass.html)
I set PGPASSFILE
environment variable to point
to pgpass.conf location. Even then, it’s throwing same above
error message. I
have found out that pgagent is not reading pgpass.conf file
when configured
under LocalSystem account.
When I
change the properties of the pgagent service to run
under my login user account. Then, it’s reading pgpass.conf
file under
%APPDATA%/postgresql/pgpass.conf.