How to enable pgAgent for remote server

Supriya Khosare
Supriya Khosare
  • Updated

This article explains how to use pgAgent from a remote server and how to autostart it.

How to use pgAgent

The difficulty that is usually encountered is where to pass the above options when starting pgAgent. You can use the available options by running the following command:

/usr/edb/as16/bin/pgagent -s /var/log/edb/pgagent16/pgagent.log host= dbname=edb user=enterprisedb port=5444      

We can also directly add an option to the command as mentioned in the edb-pgagent-16.service file:

ExecStart=/usr/edb/as16/bin/pgagent -t 2 -r 12 -l 2 -s ${LOGFILE} host=${DBHOST} dbname=${DBNAME} user=${DBUSER} port=${DBPORT}

There is no limit on the maximum number that can be set with the pgAgent option -t.

The sample log will be as follows:

tailf /var/log/edb/pgagent16/pgagent.log  
Wed Oct 11 07:26:21 2023 DEBUG: Sleeping...
Wed Oct 11 07:26:31 2023 DEBUG: Clearing inactive connections
Wed Oct 11 07:26:31 2023 DEBUG: Connection stats: total - 1, free - 0, deleted - 0
Wed Oct 11 07:26:31 2023 DEBUG: Checking for jobs to run
Wed Oct 11 07:26:31 2023 DEBUG: Sleeping...
Wed Oct 11 07:26:41 2023 DEBUG: Clearing inactive connections

Another commonly encountered difficulty is that when we start database service as systemctl start edb-as-16.service it will not start the pgAgent. You need to use systemctl start edb-pgagent-16.service command explicitly to start it. However, if we stop the database as systemctl stop edb-as-16.service it will stop both database and pgAgent service. So to make pgAgent start automatically, you can add the line Restart=always in the service file of pgAgent.

Add the below in the pgAgent service file:


Reload the daemon, using the following command:

systemctl reload edb-pgagent-16.service

Configuring PGAgent to connect to a remote PostgreSQL server

It is also possible to configure pgAgent to connect to a remote PostgreSQL server. You can edit the parameters as per your environment in the file /etc/sysconfig/edb/pgagent16/edb-pgagent-16.conf.

[root@localhost ~]# cat  /etc/sysconfig/edb/pgagent16/edb-pgagent-16.conf

Here, we pass the remote server IP address for DBHOST or we can also add remote-ip against host entry as below in the edb-pgagent-16.service file:

/usr/edb/as16/bin/pgagent -s /var/log/edb/pgagent16/pgagent.log host=remote-ip dbname=edb user=enterprisedb port=5444

So in summary:

  1. pgAgent does not work for the read-only server, hence we can not use it for standby servers.
  2. We can configure pgAgent for remote servers.
  3. We can edit the service file to start pgAgent automatically when we start the db service.
Reference link:

Was this article helpful?

0 out of 0 found this helpful