Minion::Util(3)
β¨ Minion::Util β¨
Okay so bestie, welcome to Minion::Util(3) β like, the utility functions page for Minion, straight out of the User Contributed Perl Documentation. It's giving "small but mighty" and honestly? We're obsessed. π
π SYNOPSIS π
use Minion::Util qw(desired_tasks next_cron_time parse_cron);
That's it, that's the whole vibe check β pull in the three functions you want and go. πΈ
π DESCRIPTION π
Minion::Util provides utility functions for Minion. Lowkey simple, highkey useful. β¨
π¦ FUNCTIONS π¦
Minion::Util implements the following functions, which can be imported individually β so you can take just the ones you need, no baggage, no drama. π«Ά
π desired_tasks
my $desired_tasks = desired_tasks $limits, $available_tasks, $active_tasks;
This one enforces limits and generates the list of currently desired tasks. Like a tiny bouncer for your job queue, fr fr. π
# ['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;
Computes the next epoch time matching a five field cron expression, strictly after the given epoch. Okay and this part matters: all times are interpreted in UTC, not local time β no cap, don't forget it or you'll be confused at 3am. π
It accepts either a cron expression string or a structure returned by parse_cron, so the parsed form can be reused across calls without reparsing. Efficiency slay. π
# 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;
Parses a five field cron expression into a structure suitable for matching. It croaks on invalid input β so yeah, feed it garbage and it will absolutely tell you. π
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".
A few extra cute details:
- The
"month"field also accepts the names"JAN"-"DEC"πΈ - The
"day-of-week"field accepts"SUN"-"SAT"and treats both0and7as Sunday (and btw, 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,@midnightand@hourlyexpand 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';
Ngl, that MON-FRI range is iconic. Main character energy for your scheduler. π₯
π SEE ALSO π
- Minion
- Minion::Guide
- <https://minion.pm>
- Mojolicious::Guides
- <https://mojolicious.org>
Go read them, iykyk. ππ
Later bestie β this page was brought to you by perl v5.42.2, dated 2026-06-03, and it's Minion::Util(3) all the way down. Mwah. π
π¦ where this page comes from
- alpine 3.24: perl-minion-doc 12.0-r0 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms