Postgresql Run ‘Jobs’ At Specific Times

jobspostgresqlpostgresql-9.2

I have a normal problem to anyone that can't trust on applications to do their 'work/ AKA be online' and needs a DB Stored Procedure to run every minute .

Scenario :

  • PostgreSQL 9.2
  • Need To Run A SP To 'Compile' Information That has been inserted into the database.
  1. No I Can't trust the App to be online and call this on the client side.

  2. Job(s) must execute every minute.

  3. Unfortunately I can't use trigger based or any 'EventBased' Model since I don't know when all the data has arrived.

  4. The cluster is made of headless machines.

  5. I could install CRON on every server but that could cause unnecessary chatter
    inside the Cluster , DeadLocks , Calls at 3 AM , Pain , etc

Problem 1:
Now my problem is PGAgent requires ( As far as I know) a GUI , X and so on things I would like to avoid specially for 'just' running jobs.

Problem 2:
Also what if the server that runs the Agent ( call it Master ) dies the cluster will self heal but will the agent survive?

So how do you do it?

Best Answer

pgAgent does not require a graphical user interface at all. It is a process that runs as daemon on unix. pgAdmin is used for configuring the job details. The configuration is stored in database postgres where pgAgent will read it. Once you configured your jobs, you may disconnect pgAdmin safely.