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

NameTypeDescription
procREGPROCName of the function or procedure to register as job
schedule_intervalINTERVALInterval between executions of this job

Optional Arguments

NameTypeDescription
configJSONBJob-specific configuration (this will be passed to the function when executed)
initial_startTIMESTAMPTZTime of first execution of job
scheduledBOOLEANSet to FALSE to exclude this job from scheduling. Defaults to TRUE.

Returns

ColumnTypeDescription
job_idINTEGERTimescaleDB 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.