Hi i am new to postgres … I am trying to run a insert query with PGAgent by creating a job in my Postgres Database but it won’t work. If I copy the Statement and run it manually it works just perfect. Server OS is Centos. When I am trying to do the same in my local windows system it’s working fine.
No error msg at all ..job is not at starting ..I scheduled for every minute…
Even when I run the job manually it’s showing the msg as “Updated the next ti time to now”.
But it’s not at atll starting. Sure Pgagent is running.
DO $$
DECLARE
jid integer;
scid integer;
BEGIN
-- Creating a new job
INSERT INTO pgagent.pga_job(
jobjclid, jobname, jobdesc, jobhostagent, jobenabled
) VALUES (
1::integer, 'testjob85'::text, ''::text, 'localhost'::text, true
) RETURNING jobid INTO jid;
-- Steps
-- Inserting a step (jobid: NULL)
INSERT INTO pgagent.pga_jobstep (
jstjobid, jstname, jstenabled, jstkind,
jstconnstr, jstdbname, jstonerror,
jstcode, jstdesc
) VALUES (
jid, 'step1-85'::text, true, 's'::character(1),
'user=postgres host=10.102.3.85 port=5432 dbname=postgres password=postgres'::text, ''::name, 'f'::character(1),
'insert into jobs(entry_job) values(now());'::text, ''::text
) ;
-- Schedules
-- Inserting a schedule
INSERT INTO pgagent.pga_schedule(
jscjobid, jscname, jscdesc, jscenabled,
jscstart, jscend, jscminutes, jschours, jscweekdays, jscmonthdays, jscmonths
) VALUES (
jid, 'schedule85'::text, ''::text, true,
'2024-09-24 11:35:00+05:30'::timestamp with time zone, '2024-09-24 18:00:00+05:30'::timestamp with time zone,
-- Minutes
'{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,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}'::bool[]::boolean[],
-- Hours
'{t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t}'::bool[]::boolean[],
-- Week days
'{t,t,t,t,t,t,t}'::bool[]::boolean[],
-- Month days
'{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}'::bool[]::boolean[],
-- Months
'{t,t,t,t,t,t,t,t,t,t,t,t}'::bool[]::boolean[]
) RETURNING jscid INTO scid;
END
$$;
SaiPrasad is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.