Using PgAgent with SQL commands only?

From: Csányi Pál <csanyipal(at)gmail(dot)com>
To: pgsql general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Using PgAgent with SQL commands only?
Date: 2025-02-05 18:05:49
Message-ID: CAONhAotk=VP6V6zDtzqAQ+ENDhkRZt+4nNjW44U3fGT9j0O_Mg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I am using Debian 12 operating system and
have installed on it

postgresql 15.10 (Debian 15.10-0+deb12u1)

and

pgagent -V
PostgreSQL Scheduling Agent
Version: 4.2.2

booth installed with apt.

PgAgent is running as service:
systemctl status pgagent
● pgagent.service - pgAgent for PostgreSQL
Loaded: loaded (/etc/systemd/system/pgagent.service; enabled;
preset: enabled)
Active: active (running) since Sun 2025-02-02 08:27:43 CET; 3 days ago
Process: 92063 ExecStart=/usr/bin/pgagent -s ${LOGFILE} -l
${LOGLEVEL} host=${DBHOST} dbname=${DBNAME} user=${DBUSER}
port=${DBPORT} (code=exited, status=0/SUCCESS)
Main PID: 92064 (pgagent)
Tasks: 1 (limit: 6999)
Memory: 4.4M
CPU: 10.913s
CGroup: /system.slice/pgagent.service
└─92064 /usr/bin/pgagent -s /var/log/pgagent/pgagent.log
-l 1 host=localhost dbname=postgres user=pgagent port=5432

Because I can't install and run correct PgAdmin 4 on this system
I am trying to use PgAgent with SQL commands, so far without any success.

I did the following to create a job, jobstep and schedule for that job:
(This is just a test for me to see whether I can use PgAgent with SQL commands.
This example job should dump my database every five minutes.)

For this purpose these are my SQL commands which I did run sofar:

sudo su - postgres
psql

INSERT INTO pgagent.pga_job (jobjclid, jobname, jobdesc, jobhostagent,
jobenabled, jobcreated, jobchanged, jobagentid, jobnextrun,
joblastrun)
VALUES (3, 'otpercenkent_menti_vagyonunk_kezelese_t', 'Ötpercenként
menti vagyonunk_kezelese adattelepet.', '', TRUE, DEFAULT, DEFAULT,
NULL, NULL, NULL);

INSERT INTO pgagent.pga_jobstep (jstjobid, jstname, jstdesc,
jstenabled, jstkind, jstcode, jstconnstr, jstdbname, jstonerror,
jscnextrun)
VALUES ((SELECT jobid FROM pgagent.pga_job WHERE jobname =
'otpercenkent_menti_vagyonunk_kezelese_t'),
'menti_vagyonunk_kezelese_t', 'Menti vagyonunk_kezelese adattelepet.',
TRUE,
'b', '/home/pali/Dokumentumok/AdatTelepeim/PgAgent/PgAgent_Hasznalata/pgagent_pg_dump_vagyonunk_kezelese.sh',DEFAULT
, '', DEFAULT, NULL);

INSERT INTO pgagent.pga_schedule (jscjobid, jscname, jscdesc,
jscenabled, jscstart, jscend, jscminutes, jschours, jscweekdays,
jscmonthdays, jscmonths)
VALUES ((SELECT jobid FROM pgagent.pga_job WHERE jobname =
'otpercenkent_menti_vagyonunk_kezelese_t'),'menti_vagyonunk_kezelese_t',
'Menti vagyonunk_kezelese adattelepet.', TRUE, now(), NULL,
-- jscminutes [60]
'{f,f,f,f,f,t,f,f,f,f,t,f,f,f,f,t,f,f,f,f,t,f,f,f,f,t,f,f,f,f,t,f,f,f,f,t,f,f,f,f,t,f,f,f,f,t,f,f,f,f,t,f,f,f,f,t,f,f,f,f}',
-- jschours [24]
'{t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t}',
-- jscweekdays [7]
'{t,t,t,t,t,t,t}',
-- jscmonthdays [32]
'{t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t}',
-- jscmonths [12]
'{t,t,t,t,t,t,t,t,t,t,t,t}');

So this way I have created a pga_job, a pga_jobstep and a pga_schedule
but this job won't run every five minutes.

What am I missing here?

Any suggestions will be appreciated!

--
Best, Paul Chany

Browse pgsql-general by date

  From Date Subject
Next Message Thiemo Kellner 2025-02-05 18:07:30 Re: Lookup tables
Previous Message Andy Hartman 2025-02-05 17:46:35 Re: Table copy