Minion::Util(3)

πŸ“¦
version 12.0 Β· 4 versions
, in alpine 3.24

✨ 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 both 0 and 7 as 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, @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';
Ngl, that MON-FRI range is iconic. Main character energy for your scheduler. πŸ”₯

πŸ‘€ SEE ALSO πŸ‘€

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