Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Cronjob Extension #196

Merged
merged 1 commit into from
Nov 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions extensions/cronjob/description.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
extension:
name: cronjob
description: DuckDB HTTP Cronjob Extension
version: 0.0.1
language: C++
build: cmake
license: MIT
maintainers:
- lmangani

repo:
github: quackscience/duckdb-extension-cronjob
ref: 719904edf23617da02dfb599643452abf51db30e

docs:
hello_world: |
-- 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)
│ │ │ │ │ │
* * * * * *


extended_description: |
This extension is experimental and potentially unstable. Do not use it in production.
Loading