add_job() Community

Register an action to be scheduled by our automation framework. Please read the instructions for more details including multiple example actions.

Required Arguments

NameDescription
proc(REGPROC) Name of the function or procedure to register as job
schedule_interval(INTERVAL) Interval between executions of this job

Optional Arguments

NameDescription
config(JSONB) Job-specific configuration (this will be passed to the function when executed)
initial_start(TIMESTAMPTZ) Time of first execution of job
scheduled(BOOLEAN) Set to FALSE to exclude this job from scheduling. Defaults to TRUE.

Returns

ColumnDescription
job_id(INTEGER) TimescaleDB background job id

Sample Usage

  1. CREATE OR REPLACE PROCEDURE user_defined_action(job_id int, config jsonb) LANGUAGE PLPGSQL AS
  2. $$
  3. BEGIN
  4. RAISE NOTICE 'Executing action % with config %', job_id, config;
  5. END
  6. $$;
  7. SELECT add_job('user_defined_action','1h');

Register the procedure user_defined_action to be run every hour.