Search Shortcut cmd + k | ctrl + k
cronjob

DuckDB HTTP Cronjob Extension

Maintainer(s): lmangani

Installing and Loading

INSTALL cronjob FROM community;
LOAD cronjob;

Example

-- Every 15 seconds during hours 1-4
SELECT cron('SELECT now()', '*/15 * 1-4 * * *');

-- Every 2 hours (at minute 0, second 0) during hours 1-4
SELECT cron('SELECT version()', '0 0 */2 1-4 * *');

-- Every 5 minute (wipe old data)
SELECT cron('DELETE FROM somewhere WHERE ts < NOW() - INTERVAL ''1 hour''', '* /5 * * * *');

-- Inspect running Jobs
SELECT * FROM cron_jobs();

┌─────────┬──────────────────┬────────────────┬──────────────────────────┬─────────┬──────────────────────────┬─────────────┐
 job_id        query           schedule             next_run          status           last_run          last_result 
 varchar      varchar          varchar              varchar           varchar          varchar             varchar   
├─────────┼──────────────────┼────────────────┼──────────────────────────┼─────────┼──────────────────────────┼─────────────┤
 task_0   SELECT version()  */15 * * * * *  Fri Nov 15 20:44:30 2024  Active   Fri Nov 15 20:44:15 2024  Success     
└─────────┴──────────────────┴────────────────┴──────────────────────────┴─────────┴──────────────────────────┴─────────────┘

-- Inspect running Jobs
SELECT cron_delete('task_0');

-- Supported Patterns
┌───────────── second (0 - 59)
 ┌───────────── minute (0 - 59)
  ┌───────────── hour (0 - 23)
   ┌───────────── day of month (1 - 31)
    ┌───────────── month (1 - 12)
     ┌───────────── day of week (0 - 6) (Sunday to Saturday)
     
* * * * * *

About cronjob

This extension is experimental and potentially unstable. Do not use it in production.

Added Functions

function_name function_type description comment examples
cron scalar NULL NULL  
cron_delete scalar NULL NULL  
cron_jobs table NULL NULL  

Overloaded Functions

This extension does not add any function overloads.

Added Types

This extension does not add any types.

Added Settings

This extension does not add any settings.