PostgreSQL – How to Determine if pgAgent is Installed

postgresql

I have inherited some problems and I need to determine if pgAgent exists on some number of installations (CentOS) and is running background jobs. These jobs could be run from cron, pgAgent, or an external caller.

If I am looking at a postgres instance and not using pgAdmin, how can I determine if pgAgent is installed?

Can this be done from the command line or from the psql client? I'd prefer that to pgAdmin if possible.

Best Answer

From Database setup:

pgAgent stores its configuration in the ‘postgres’ database in your cluster

And it creates there a schema named pgagent with a handful of tables prefixed by pga_

It's probably good enough to connect to the postgres database and interpret the result of:

select 1  from information_schema.schemata  where schema_name='pgagent';

Due to how information_schema.schemata is restricted, the above should be run as postgres user (otherwise consider querying directly pg_namespace as the non-standard alternative).