Main Tutorials

How to install pgAgent on windows (PostgreSQL Job Scheduler)

This is a surprise for me that PostgreSQL do not have any build-in job scheduler. However It did pack into pgAdmin source but i wonder why it didnt intsall it by default? Here i provide some steps to show how to install pgAgent(Job Scheduler) on windows as services

1) Go to your PgAdim file path like below, please change to your own pgAdmin file path like “C:\Program Files\PostgreSQL\8.2\pgAdmin III”

pgagent-install-step1

2) Get pgAgent.sql and execute the script, it will create all pgAgent core tables

pgagent-install-step2

3) After executed pgAgent script, user will notice one job icon appear at pgAdmin.

pgagent-install-step3

4) Job scheduler is still not working yet, you have to register it as services in windows. Please issue following command on command prompt

C:\Program Files\PostgreSQL\8.2\bin\pgAgent INSTALL pgAgent -u postgres 
-p secret hostaddr=127.0.0.1 dbname=newdb user=postgres password=secret

please issue C:\Program Files\PostgreSQL\8.2\bin\pgAgent to show usage of pgAgent, where
-u = username
-p = password
“hostaddr=127.0.0.1 dbname=newdb user=postgres password=secret” = connect string

P.S please notice INSTALL is all uppercase, do not type lowercase , it will not work.

5) After registered service on windows, just go windows service to start it or use net start command.

pgagent-install-step4

6) Done, we can start to schedule our job now.

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
24 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Cris
4 years ago

hi, I’m Cris, from Colombia, I’m trying to install de PGAgent using the StackBuilder in a Server, but, I’m having some issues… I follow the tutorial but I don’t have good results…
shorturl.at/ahANT

Anvesh Patel
8 years ago

Nice Article…
I was also facing problem with configuration of pgAgent in windows.
I have also asked in stackoverflow.
http://stackoverflow.com/questions/17567168/how-to-install-pgagent-service-on-windows
Now my problem is resolved.

I have also prepared one post on this.
Please visit this url:
http://www.dbrnd.com/2015/05/how-to-create-job-in-postgresql/

Suchismita
10 years ago

Sir, Thanks for the guide to install pgAgent. I followed these steps,I have successfully did till step 3 but not able to do step 4 installation. One doubt
C:\Program Files\PostgreSQL\8.2\bin\pgAgent
here “pgAgent” is one folder, which I need to place or what?? I kept pgAgent.sql file in pgAdmin 3 only. In command prompt its showing the below error:
D:\PostgreSQL\8.4\bin>pgAgent INSTALL pgAgent
‘pgAgent’ is not recognized as an internal or external command,
operable program or batch file.
Please suggest me what to do next.
Thanks
Suchismita

Jardel Morais
9 years ago
Reply to  Suchismita

I have the same problem..

victor
10 years ago

Not so far I have found new cool tool to work with postgresql on win – Valentina Studio. Its free edition can do things more than many commercial tools!!
I very recommend check it. http://www.valentina-db.com/en/valentina-studio-overview

Tom
11 years ago

I did exact same steps which are mentioned above.
When after the 4th step I am trying to start the service, I observe that service is not listed in control panel.

Any suggestions?

Vidushi Gupta
11 years ago

Respected sir,
I am working in postgreSQL 8.1.I want to know how to schedule jobs in PostgreSQL 8.1.
Please mail me as soon as possible

Dilip Shaik
4 years ago
Reply to  Vidushi Gupta

Hi Sir,
Please send me the script of postgres database schedule script in windows environment.

Sithlord
13 years ago

Hi,

thanks for this short tutorial. Really helped me a lot!
(although my job still does nothing – but at least the window service is installed and working)

When I face those problems, I understand, why all the world is using MySQL.
I just dont understand why one wouldnt make such things way easier to impelent so that every beginner can get it started.

The offcial available tutorial for installing pgAgent is a joke.

Greetings

kp
14 years ago

Hi,

I am trying to install the service (pgAgent) on windows vista and xp
getting the following error

D:\Program Files\PostgreSQL\8.3\bin>
pgAgent INSTALL pgAgent
18:49:18: Error: Can’t open registry key ‘HKLM\SYSTEM\CurrentControlSet\Services
\EventLog\Application\pgAgent’ (error 5: access is denied.)
18:49:18: Error: Can’t set value of ‘HKLM\SYSTEM\CurrentControlSet\Services\Even
tLog\Application\pgAgent\EventMessageFile’ (error 5: access is denied.)
18:49:18: Error: Can’t open registry key ‘HKLM\SYSTEM\CurrentControlSet\Services
\EventLog\Application\pgAgent’ (error 5: access is denied.)
18:49:18: Error: Can’t set value of ‘HKLM\SYSTEM\CurrentControlSet\Services\Even
tLog\Application\pgAgent\TypesSupported’ (error 5: access is denied.)

Please suggest/advise. Is there any simple exe file which could install this?

jana
11 years ago
Reply to  kp

run as administrator

kamaraju
15 years ago

I am unable to notice one job icon appear at pgAdmin.

Mildred Caballeros
11 years ago
Reply to  kamaraju

I have the same problem, I checked that the new schema “pgagent” is created but I cannot see it, I made a select of the tables and I got the results. The installation was successfull and I started the windows service. The only problem is that I dont have access to the JOBs Icon, therefore I cannot create any job to test the services. In advance, thank you for your help.

indraES-indonesia
15 years ago

3) Error 1069: the service did not start due to a logon failure?

Look like a postgres authentication error, please make sure user you assigned had right to access the postgresDB
—————————————————————————–

hm…….
ok.. thanks a lot..

indraES-indonesia
15 years ago

C:\Program Files\PostgreSQL\8.2\bin\pgAgent to show usage of pgAgent, where
-u = username
-p = password
“hostaddr=127.0.0.1 dbname=newdb user=postgres password=secret” = connect string
…………….
(1)
i still confuse about
u=username ——-> user login to postgre db? or new user for pgAgent?
p=password

“hostaddr=127.0.0.1 dbname=newdb user=postgres password=secret” —> fix(cannot modification)?

(2)
i follow the step until no.5,
every i click start the pgAgent the error message show=

could not start the PostgreSQL scheduling Agent-pgagent service on local computer
Error 1069: the service did not start due to a logon failur

do you have solution about my error…
thanks

nafg
13 years ago
Reply to  mkyong

Logon failure means windows logon failure. The initial -u and -p options are supposed to be the login account that the service should run under. I assume it should be the postgres windows user and whatever password you assigned it.
I got past that error though and now I’m getting an Error 5: Access Denied when trying to start the service…

Salma
15 years ago

the OS supported for the product under development is SLES 10 64bit

Salma
15 years ago

Does this version of postgres come with a build-in job scheduler? “PostgreSQL 8.3.3 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20070115 (prerelease) (SUSE Linux)”

One of the projects in our company that is being developed is using that version. I’m told that they implemented a Java Scheduler to schedule partition jobs. Assuming the version I mentioned comes with a build-in job scheduler, I’m curious to know why they must have implemented it. I mean, if at all it is there, are there any known issues with it? If it doesn’t come with a build-in job scheduler, is there anything like you mentioned above so that we can install and start using it instead? Also, it would be great if you can list out some known issues with this version.