cron_utils
解析 Cron 表达式并计算上一次或下一次触发时间
仓库
Myshkouski/pg-cron-utils
https://github.com/Myshkouski/pg-cron-utils
源码
cron_utils-0.1.0.tar.gz
cron_utils-0.1.0.tar.gz
概览
| 扩展包名 | 版本 | 分类 | 许可证 | 语言 |
|---|---|---|---|---|
cron_utils | 0.1.0 | TIME | MIT | SQL |
| ID | 扩展名 | Bin | Lib | Load | Create | Trust | Reloc | 模式 |
|---|---|---|---|---|---|---|---|---|
| 1140 | cron_utils | 否 | 否 | 否 | 是 | 否 | 是 | - |
| 相关扩展 | pg_cron pgcalendar pg_rrule pg_when pgagent pg_task pg_dbms_job pg_duration pg_bikram_sambat pg_dispatch |
|---|
The PGXN 0.1.0 distribution is marked unstable; the control file marks the extension relocatable.
版本
| 类型 | 仓库 | 版本 | PG 大版本 | 包名 | 依赖 |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.1.0 | 1817161514 | cron_utils | - |
| RPM | PIGSTY | 0.1.0 | 1817161514 | cron_utils_$v | - |
| DEB | PIGSTY | 0.1.0 | 1817161514 | postgresql-$v-cron-utils | - |
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 0.1.0 el8.x86_64.pg18 : cron_utils_18 cron_utils_18-0.1.0-1PIGSTY.el8.noarch.rpm
| PIGSTY 0.1.0 el8.x86_64.pg17 : cron_utils_17 cron_utils_17-0.1.0-1PIGSTY.el8.noarch.rpm
| PIGSTY 0.1.0 el8.x86_64.pg16 : cron_utils_16 cron_utils_16-0.1.0-1PIGSTY.el8.noarch.rpm
| PIGSTY 0.1.0 el8.x86_64.pg15 : cron_utils_15 cron_utils_15-0.1.0-1PIGSTY.el8.noarch.rpm
| PIGSTY 0.1.0 el8.x86_64.pg14 : cron_utils_14 cron_utils_14-0.1.0-1PIGSTY.el8.noarch.rpm
|
| el8.aarch64 | PIGSTY 0.1.0 el8.aarch64.pg18 : cron_utils_18 cron_utils_18-0.1.0-1PIGSTY.el8.noarch.rpm
| PIGSTY 0.1.0 el8.aarch64.pg17 : cron_utils_17 cron_utils_17-0.1.0-1PIGSTY.el8.noarch.rpm
| PIGSTY 0.1.0 el8.aarch64.pg16 : cron_utils_16 cron_utils_16-0.1.0-1PIGSTY.el8.noarch.rpm
| PIGSTY 0.1.0 el8.aarch64.pg15 : cron_utils_15 cron_utils_15-0.1.0-1PIGSTY.el8.noarch.rpm
| PIGSTY 0.1.0 el8.aarch64.pg14 : cron_utils_14 cron_utils_14-0.1.0-1PIGSTY.el8.noarch.rpm
|
| el9.x86_64 | PIGSTY 0.1.0 el9.x86_64.pg18 : cron_utils_18 cron_utils_18-0.1.0-1PIGSTY.el9.noarch.rpm
| PIGSTY 0.1.0 el9.x86_64.pg17 : cron_utils_17 cron_utils_17-0.1.0-1PIGSTY.el9.noarch.rpm
| PIGSTY 0.1.0 el9.x86_64.pg16 : cron_utils_16 cron_utils_16-0.1.0-1PIGSTY.el9.noarch.rpm
| PIGSTY 0.1.0 el9.x86_64.pg15 : cron_utils_15 cron_utils_15-0.1.0-1PIGSTY.el9.noarch.rpm
| PIGSTY 0.1.0 el9.x86_64.pg14 : cron_utils_14 cron_utils_14-0.1.0-1PIGSTY.el9.noarch.rpm
|
| el9.aarch64 | PIGSTY 0.1.0 el9.aarch64.pg18 : cron_utils_18 cron_utils_18-0.1.0-1PIGSTY.el9.noarch.rpm
| PIGSTY 0.1.0 el9.aarch64.pg17 : cron_utils_17 cron_utils_17-0.1.0-1PIGSTY.el9.noarch.rpm
| PIGSTY 0.1.0 el9.aarch64.pg16 : cron_utils_16 cron_utils_16-0.1.0-1PIGSTY.el9.noarch.rpm
| PIGSTY 0.1.0 el9.aarch64.pg15 : cron_utils_15 cron_utils_15-0.1.0-1PIGSTY.el9.noarch.rpm
| PIGSTY 0.1.0 el9.aarch64.pg14 : cron_utils_14 cron_utils_14-0.1.0-1PIGSTY.el9.noarch.rpm
|
| el10.x86_64 | PIGSTY 0.1.0 el10.x86_64.pg18 : cron_utils_18 cron_utils_18-0.1.0-1PIGSTY.el10.noarch.rpm
| PIGSTY 0.1.0 el10.x86_64.pg17 : cron_utils_17 cron_utils_17-0.1.0-1PIGSTY.el10.noarch.rpm
| PIGSTY 0.1.0 el10.x86_64.pg16 : cron_utils_16 cron_utils_16-0.1.0-1PIGSTY.el10.noarch.rpm
| PIGSTY 0.1.0 el10.x86_64.pg15 : cron_utils_15 cron_utils_15-0.1.0-1PIGSTY.el10.noarch.rpm
| PIGSTY 0.1.0 el10.x86_64.pg14 : cron_utils_14 cron_utils_14-0.1.0-1PIGSTY.el10.noarch.rpm
|
| el10.aarch64 | PIGSTY 0.1.0 el10.aarch64.pg18 : cron_utils_18 cron_utils_18-0.1.0-1PIGSTY.el10.noarch.rpm
| PIGSTY 0.1.0 el10.aarch64.pg17 : cron_utils_17 cron_utils_17-0.1.0-1PIGSTY.el10.noarch.rpm
| PIGSTY 0.1.0 el10.aarch64.pg16 : cron_utils_16 cron_utils_16-0.1.0-1PIGSTY.el10.noarch.rpm
| PIGSTY 0.1.0 el10.aarch64.pg15 : cron_utils_15 cron_utils_15-0.1.0-1PIGSTY.el10.noarch.rpm
| PIGSTY 0.1.0 el10.aarch64.pg14 : cron_utils_14 cron_utils_14-0.1.0-1PIGSTY.el10.noarch.rpm
|
| d12.x86_64 | PIGSTY 0.1.0 d12.x86_64.pg18 : postgresql-18-cron-utils postgresql-18-cron-utils_0.1.0-1PIGSTY~bookworm_all.deb
| PIGSTY 0.1.0 d12.x86_64.pg17 : postgresql-17-cron-utils postgresql-17-cron-utils_0.1.0-1PIGSTY~bookworm_all.deb
| PIGSTY 0.1.0 d12.x86_64.pg16 : postgresql-16-cron-utils postgresql-16-cron-utils_0.1.0-1PIGSTY~bookworm_all.deb
| PIGSTY 0.1.0 d12.x86_64.pg15 : postgresql-15-cron-utils postgresql-15-cron-utils_0.1.0-1PIGSTY~bookworm_all.deb
| PIGSTY 0.1.0 d12.x86_64.pg14 : postgresql-14-cron-utils postgresql-14-cron-utils_0.1.0-1PIGSTY~bookworm_all.deb
|
| d12.aarch64 | PIGSTY 0.1.0 d12.aarch64.pg18 : postgresql-18-cron-utils postgresql-18-cron-utils_0.1.0-1PIGSTY~bookworm_all.deb
| PIGSTY 0.1.0 d12.aarch64.pg17 : postgresql-17-cron-utils postgresql-17-cron-utils_0.1.0-1PIGSTY~bookworm_all.deb
| PIGSTY 0.1.0 d12.aarch64.pg16 : postgresql-16-cron-utils postgresql-16-cron-utils_0.1.0-1PIGSTY~bookworm_all.deb
| PIGSTY 0.1.0 d12.aarch64.pg15 : postgresql-15-cron-utils postgresql-15-cron-utils_0.1.0-1PIGSTY~bookworm_all.deb
| PIGSTY 0.1.0 d12.aarch64.pg14 : postgresql-14-cron-utils postgresql-14-cron-utils_0.1.0-1PIGSTY~bookworm_all.deb
|
| d13.x86_64 | PIGSTY 0.1.0 d13.x86_64.pg18 : postgresql-18-cron-utils postgresql-18-cron-utils_0.1.0-1PIGSTY~trixie_all.deb
| PIGSTY 0.1.0 d13.x86_64.pg17 : postgresql-17-cron-utils postgresql-17-cron-utils_0.1.0-1PIGSTY~trixie_all.deb
| PIGSTY 0.1.0 d13.x86_64.pg16 : postgresql-16-cron-utils postgresql-16-cron-utils_0.1.0-1PIGSTY~trixie_all.deb
| PIGSTY 0.1.0 d13.x86_64.pg15 : postgresql-15-cron-utils postgresql-15-cron-utils_0.1.0-1PIGSTY~trixie_all.deb
| PIGSTY 0.1.0 d13.x86_64.pg14 : postgresql-14-cron-utils postgresql-14-cron-utils_0.1.0-1PIGSTY~trixie_all.deb
|
| d13.aarch64 | PIGSTY 0.1.0 d13.aarch64.pg18 : postgresql-18-cron-utils postgresql-18-cron-utils_0.1.0-1PIGSTY~trixie_all.deb
| PIGSTY 0.1.0 d13.aarch64.pg17 : postgresql-17-cron-utils postgresql-17-cron-utils_0.1.0-1PIGSTY~trixie_all.deb
| PIGSTY 0.1.0 d13.aarch64.pg16 : postgresql-16-cron-utils postgresql-16-cron-utils_0.1.0-1PIGSTY~trixie_all.deb
| PIGSTY 0.1.0 d13.aarch64.pg15 : postgresql-15-cron-utils postgresql-15-cron-utils_0.1.0-1PIGSTY~trixie_all.deb
| PIGSTY 0.1.0 d13.aarch64.pg14 : postgresql-14-cron-utils postgresql-14-cron-utils_0.1.0-1PIGSTY~trixie_all.deb
|
| u22.x86_64 | PIGSTY 0.1.0 u22.x86_64.pg18 : postgresql-18-cron-utils postgresql-18-cron-utils_0.1.0-1PIGSTY~jammy_all.deb
| PIGSTY 0.1.0 u22.x86_64.pg17 : postgresql-17-cron-utils postgresql-17-cron-utils_0.1.0-1PIGSTY~jammy_all.deb
| PIGSTY 0.1.0 u22.x86_64.pg16 : postgresql-16-cron-utils postgresql-16-cron-utils_0.1.0-1PIGSTY~jammy_all.deb
| PIGSTY 0.1.0 u22.x86_64.pg15 : postgresql-15-cron-utils postgresql-15-cron-utils_0.1.0-1PIGSTY~jammy_all.deb
| PIGSTY 0.1.0 u22.x86_64.pg14 : postgresql-14-cron-utils postgresql-14-cron-utils_0.1.0-1PIGSTY~jammy_all.deb
|
| u22.aarch64 | PIGSTY 0.1.0 u22.aarch64.pg18 : postgresql-18-cron-utils postgresql-18-cron-utils_0.1.0-1PIGSTY~jammy_all.deb
| PIGSTY 0.1.0 u22.aarch64.pg17 : postgresql-17-cron-utils postgresql-17-cron-utils_0.1.0-1PIGSTY~jammy_all.deb
| PIGSTY 0.1.0 u22.aarch64.pg16 : postgresql-16-cron-utils postgresql-16-cron-utils_0.1.0-1PIGSTY~jammy_all.deb
| PIGSTY 0.1.0 u22.aarch64.pg15 : postgresql-15-cron-utils postgresql-15-cron-utils_0.1.0-1PIGSTY~jammy_all.deb
| PIGSTY 0.1.0 u22.aarch64.pg14 : postgresql-14-cron-utils postgresql-14-cron-utils_0.1.0-1PIGSTY~jammy_all.deb
|
| u24.x86_64 | PIGSTY 0.1.0 u24.x86_64.pg18 : postgresql-18-cron-utils postgresql-18-cron-utils_0.1.0-1PIGSTY~noble_all.deb
| PIGSTY 0.1.0 u24.x86_64.pg17 : postgresql-17-cron-utils postgresql-17-cron-utils_0.1.0-1PIGSTY~noble_all.deb
| PIGSTY 0.1.0 u24.x86_64.pg16 : postgresql-16-cron-utils postgresql-16-cron-utils_0.1.0-1PIGSTY~noble_all.deb
| PIGSTY 0.1.0 u24.x86_64.pg15 : postgresql-15-cron-utils postgresql-15-cron-utils_0.1.0-1PIGSTY~noble_all.deb
| PIGSTY 0.1.0 u24.x86_64.pg14 : postgresql-14-cron-utils postgresql-14-cron-utils_0.1.0-1PIGSTY~noble_all.deb
|
| u24.aarch64 | PIGSTY 0.1.0 u24.aarch64.pg18 : postgresql-18-cron-utils postgresql-18-cron-utils_0.1.0-1PIGSTY~noble_all.deb
| PIGSTY 0.1.0 u24.aarch64.pg17 : postgresql-17-cron-utils postgresql-17-cron-utils_0.1.0-1PIGSTY~noble_all.deb
| PIGSTY 0.1.0 u24.aarch64.pg16 : postgresql-16-cron-utils postgresql-16-cron-utils_0.1.0-1PIGSTY~noble_all.deb
| PIGSTY 0.1.0 u24.aarch64.pg15 : postgresql-15-cron-utils postgresql-15-cron-utils_0.1.0-1PIGSTY~noble_all.deb
| PIGSTY 0.1.0 u24.aarch64.pg14 : postgresql-14-cron-utils postgresql-14-cron-utils_0.1.0-1PIGSTY~noble_all.deb
|
| u26.x86_64 | PIGSTY 0.1.0 u26.x86_64.pg18 : postgresql-18-cron-utils postgresql-18-cron-utils_0.1.0-1PIGSTY~resolute_all.deb
| PIGSTY 0.1.0 u26.x86_64.pg17 : postgresql-17-cron-utils postgresql-17-cron-utils_0.1.0-1PIGSTY~resolute_all.deb
| PIGSTY 0.1.0 u26.x86_64.pg16 : postgresql-16-cron-utils postgresql-16-cron-utils_0.1.0-1PIGSTY~resolute_all.deb
| PIGSTY 0.1.0 u26.x86_64.pg15 : postgresql-15-cron-utils postgresql-15-cron-utils_0.1.0-1PIGSTY~resolute_all.deb
| PIGSTY 0.1.0 u26.x86_64.pg14 : postgresql-14-cron-utils postgresql-14-cron-utils_0.1.0-1PIGSTY~resolute_all.deb
|
| u26.aarch64 | PIGSTY 0.1.0 u26.aarch64.pg18 : postgresql-18-cron-utils postgresql-18-cron-utils_0.1.0-1PIGSTY~resolute_all.deb
| PIGSTY 0.1.0 u26.aarch64.pg17 : postgresql-17-cron-utils postgresql-17-cron-utils_0.1.0-1PIGSTY~resolute_all.deb
| PIGSTY 0.1.0 u26.aarch64.pg16 : postgresql-16-cron-utils postgresql-16-cron-utils_0.1.0-1PIGSTY~resolute_all.deb
| PIGSTY 0.1.0 u26.aarch64.pg15 : postgresql-15-cron-utils postgresql-15-cron-utils_0.1.0-1PIGSTY~resolute_all.deb
| PIGSTY 0.1.0 u26.aarch64.pg14 : postgresql-14-cron-utils postgresql-14-cron-utils_0.1.0-1PIGSTY~resolute_all.deb
|
构建
您可以使用 pig build 命令构建 cron_utils 扩展的 RPM / DEB 包:
BASH
安装
您可以直接安装 cron_utils 扩展包的预置二进制包,首先确保 PGDG 和 PIGSTY 仓库已经添加并启用:
BASH
使用 pig 或者是 apt/yum/dnf 安装扩展:
安装
BASH
pig
BASH
dnf
BASH
apt
BASH
创建扩展:
SQL
用法
来源:
cron_utils 解析五字段 cron 表达式并在 PostgreSQL 中计算触发时间戳。它是一个调度工具,而不是作业执行器:使用它可以预览、验证或查询一个计划,并单独使用 pg_cron 等调度程序来执行工作。
核心流程
SQL
要检查一个限定窗口:
SQL
当表达式在窗口中没有触发时,返回的边界可以是 NULL。
重要对象
cron_parts是分钟、小时、日、月和周字段的解析表示。parse_cron(text)解析*、列表、范围以及步进语法。cron_first_trigger(expr, base_time, strict)向前搜索。当strict = true时,会跳过在base_time精确匹配的情况。cron_last_trigger(expr, base_time, strict)向后搜索,默认为严格匹配。cron_first_last_triggers(expr, start_time, end_time)返回窗口中的第一个和最后一个匹配项。cron_iterate_n(expr, base_time, strict, direction, max_matches)按next或prev方向返回连续的匹配项。
语义与注意事项
表达式使用标准的五个字段 minute hour day month dow;秒不被接受。周字段使用 1 = Monday 到 7 = Sunday 的表示方式。结果为 timestamptz,因此会话时区会影响显示的本地时间,并且对于本地时间计划应测试夏令时转换。
该扩展是纯 SQL/PL/pgSQL 实现的,可重定位且没有依赖于 pg_cron。其函数声明为不可变且并行安全。0.1.0 版本在控制元数据中标记为 unstable,因此在将其嵌入关键调度程序之前,请锁定行为并重新测试边缘情况。