File: job.sql

package info (click to toggle)
pgagent 3.4.1-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 372 kB
  • ctags: 213
  • sloc: cpp: 1,736; sql: 560; xml: 100; ansic: 53; makefile: 34; sh: 9
file content (23 lines) | stat: -rw-r--r-- 1,208 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
CREATE TABLE t (
 t timestamptz
);

WITH
 id AS
 (INSERT INTO pgagent.pga_job (jobjclid, jobname, jobdesc, jobenabled, jobhostagent)
  SELECT jcl.jclid, 'job1', '', true, ''
   FROM pgagent.pga_jobclass jcl WHERE jclname='Routine Maintenance'
  RETURNING jobid),

 insertstep AS
 (INSERT INTO pgagent.pga_jobstep (jstjobid, jstname, jstdesc, jstenabled, jstkind, jstonerror, jstcode, jstdbname, jstconnstr)
  SELECT id.jobid, 'step1', '', true, 's', 'f', 'INSERT INTO t VALUES (now())', 'contrib_regression', ''
   FROM id)

INSERT INTO pgagent.pga_schedule (jscjobid, jscname, jscdesc, jscminutes, jschours, jscweekdays, jscmonthdays, jscmonths, jscenabled, jscstart, jscend)
 SELECT id.jobid, 'schedule1', '', '{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}', '{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,t,t,t}', '{t,t,t,t,t,t,t,t,t,t,t,t}', true, '2000-01-01 00:00:00', '2099-12-31 00:00:00'
  FROM id;

\! timeout 80 pgagent -f -l 2 -s pgagent.out "user=$PGUSER dbname=contrib_regression" 2>/dev/null

SELECT count(*) > 0 AS job_run FROM t;