postgresqljobspgagent

How to run a job created via pgagent in Postgres


Created a job using pgagent.

Successfully it got created but could not check its status if its running or not.

Neither it has performed its specified code which I have given in steps.

Verion Used: PostgreSQL 9.6.2 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-17), 64-bit

With the help of pgAgent I have created a JOB

Job name and general details

Job steps and name

Job detailed code which need to be performed

Time scheduled for job

enter image description here

Job successfully got created but I cant check if its working or not as there is no notification for the same, neither it is performing the SQL code which i have passed in Job -> Step.


Solution

  • If I got it right, you installed pgAagent but it is not starting when you execute the jobs. Have you tried starting it using the terminal? The service might be down (I do start it manually every time the database system is restarted).

    Using the postgres user ...

    sudo su - postgres
    

    ... execute the following command (assuming you're on the db server):

    pgagent hostaddr=127.0.0.1 dbname=postgres user=postgres -s pgagent_log.log
    

    I hope it helps. Cheers!