Install and setup PgAgent on Debian 12 Bookworm - Mailing list pgadmin-support

From Csányi Pál
Subject Install and setup PgAgent on Debian 12 Bookworm
Date
Msg-id CAONhAos5nimrBjrPq3qHk5948Z6a6mOB_LNQuhJrPh+2fJuiaA@mail.gmail.com
Whole thread Raw
List pgadmin-support
Hello,

my operating system is Debian 12 Bookworm:
[code]cat /etc/debian_version[/code]
12.9

I have PgAdmin4-Web and PgAgent installed on my system.

I followed this advice when I installed them:
for pgAdmin 4 (APT):
https://www.pgadmin.org/download/pgadmin-4-apt/

for PgAgent:
Install pgAgent on Postgres 10 (Debian Linux)
https://gist.github.com/peterneave/83cefce2a081add244ad7dc1c53bc0c3

PgAdmin4-web works as expected!

Commands to install and set up PgAgent that I have run so far:
(following the above help on gist.github)

Terminal

1. Install pgAgent via package manager
[code]
sudo apt update
sudo apt install pgagent
[/code]

2. Create .pgpass file.
[code]
sudo su - postgres
echo localhost:5432:*:pgagent:securepassword >> ~/.pgpass
chmod 600 ~/.pgpass
chown postgres:postgres /var/lib/postgresql/.pgpass
[/code]

3. Setup Logging directory
[code]
mkdir /var/log/pgagent
chown -R postgres:postgres /var/log/pgagent
chmod g+w /var/log/pgagent
[/code]

Postgres

4. Setup pgAgent on Postgres (maintenance) Database
[code]
sudo su - postgres
psql
CREATE EXTENSION pgagent;
[/code]

Testing

5. Test pgAgent connections

In a separate terminal,
[code]
sudo tail -f /var/log/postgresql/postgresql-15-main.log
[/code]

Postgres connection
Test connection to database in terminal with

[code]
psql -h localhost -d mydatabase -U pgagent
[/code]

There is no error here.

pgAgent

[code]
sudo su - postgres
/usr/bin/pgagent -f -l 2 host=localhost port=5432 user=pgagent dbname=postgres
[/code]

There is an error here!

In postgresql-15-main.log are these errors:
[messages]
2025-02-08 15:49:10.087 CET [15472] pgagent@postgres ERROR:
permission denied for table pga_jobagent
2025-02-08 15:49:10.087 CET [15472] pgagent@postgres STATEMENT:
INSERT INTO pgagent.pga_jobagent (jagpid, jagstation) SELECT
pg_backend_pid(), 'csp4'
2025-02-08 15:49:15.161 CET [15476] pgagent@postgres ERROR:
permission denied for table pga_jobagentThe output of the following
command is:
[/messages]

The output of the next command
[code]
postgres@csp4:~$ /usr/bin/pgagent -f -l 2 host=localhost port=5432
user=pgagent dbname=postgres
[/code]

is:
[messages]
Sat Feb 8 15:49:10 2025 WARNING: Couldn't create the primary
connection [Attempt #9]
Sat Feb 8 15:49:10 2025 DEBUG: Clearing all connections
Sat Feb 8 15:49:10 2025 DEBUG: Connection stats: total - 1, free - 0,
deleted - 1
Sat Feb 8 15:49:15 2025 DEBUG: Creating primary connection
Sat Feb 8 15:49:15 2025 DEBUG: Parsing connection information...
Sat Feb 8 15:49:15 2025 DEBUG: Creating DB connection: user=pgagent
dbname=postgres host=localhost port=5432 dbname=postgres
Sat Feb 8 15:49:15 2025 DEBUG: Database sanity check
Sat Feb 8 15:49:15 2025 DEBUG: Clearing zombies
Sat Feb 8 15:49:15 2025 WARNING: Query error: ERROR:  permission
denied for table pga_jobagent

Sat Feb 8 15:49:15 2025 WARNING: Query error: ERROR:  permission
denied for table pga_jobagent

Sat Feb 8 15:49:15 2025 WARNING: Couldn't create the primary
connection [Attempt #10]
Sat Feb 8 15:49:15 2025 DEBUG: Clearing all connections
Sat Feb 8 15:49:15 2025 DEBUG: Connection stats: total - 1, free - 0,
deleted - 1
Sat Feb 8 15:49:15 2025 ERROR: Stopping pgAgent: Couldn't establish
the primary connection with the database server.
[/messages]

How do I solve this problem?
Any advice is appreciated!

--
Best wishes by Paul Chanyi!



pgadmin-support by date:

Previous
From: Eamon Doyle
Date:
Subject: Issue running pgAdmin behind a reserve proxy
Next
From: Ray O'Donnell
Date:
Subject: Mystery button