Versions:

add_job()

Register an action for scheduling by the automation framework. For more information about scheduling, including example actions, see the actions section.

Required arguments

NameTypeDescription
procREGPROCName of the function or procedure to register as job
schedule_intervalINTERVALInterval between executions of this job. Defaults to 24 hours

Optional arguments

NameTypeDescription
configJSONBJob-specific configuration, passed to the function when it runs
initial_startTIMESTAMPTZTime the job is first run
scheduledBOOLEANSet to FALSE to exclude this job from scheduling. Defaults to TRUE.

Returns

ColumnTypeDescription
job_idINTEGERTimescaleDB background job ID

Sample use

Register the user_defined_action procedure to run every hour:

CREATE OR REPLACE PROCEDURE user_defined_action(job_id int, config jsonb) LANGUAGE PLPGSQL AS
$$
BEGIN
  RAISE NOTICE 'Executing action % with config %', job_id, config;
END
$$;

SELECT add_job('user_defined_action','1h');

Found an issue on this page?

Report an issue!

Related Content