table of contents
| Minion::Util(3) | User Contributed Perl Documentation | Minion::Util(3) |
NAME¶
Minion::Util - Minion utility functions
SYNOPSIS¶
use Minion::Util qw(desired_tasks next_cron_time parse_cron);
DESCRIPTION¶
Minion::Util provides utility functions for Minion.
FUNCTIONS¶
Minion::Util implements the following functions, which can be imported individually.
desired_tasks¶
my $desired_tasks = desired_tasks $limits, $available_tasks, $active_tasks;
Enforce limits and generate list of currently desired tasks.
# ['bar']
desired_tasks {foo => 2}, ['foo', 'bar'], ['foo', 'foo'];
next_cron_time¶
my $epoch = next_cron_time $expr, $from; my $epoch = next_cron_time $parsed, $from;
Compute the next epoch time matching a five field cron expression, strictly after the given epoch. All times are interpreted in UTC, not local time. Accepts either a cron expression string or a structure returned by "parse_cron", so the parsed form can be reused across calls without reparsing.
# 1747051500 (next 12:05 UTC after 1747051200) next_cron_time '*/5 * * * *', 1747051200; # Reuse the parsed structure my $cron = parse_cron '0 4 * * *'; my $next = next_cron_time $cron, time;
parse_cron¶
my $parsed = parse_cron $expr;
Parse a five field cron expression into a structure suitable for matching. Croaks on invalid input. The supported syntax covers "*", "*/N", "a-b", "a-b/N" and comma separated lists for the fields "minute", "hour", "day-of-month", "month" and "day-of-week". The "month" field also accepts the names "JAN"-"DEC", and the "day-of-week" field accepts "SUN"-"SAT" and treats both 0 and 7 as Sunday (names are case-insensitive). When both "day-of-month" and "day-of-week" are restricted, jobs run when either matches, following the standard Vixie cron(8) behavior. The nicknames @yearly, @annually, @monthly, @weekly, @daily, @midnight and @hourly expand to the equivalent five field expression.
# Every weekday at 9 in the morning parse_cron '0 9 * * MON-FRI'; # Every day at midnight parse_cron '@daily';
SEE ALSO¶
Minion, Minion::Guide, <https://minion.pm>, Mojolicious::Guides, <https://mojolicious.org>.
| 2026-05-22 | perl v5.42.1 |