Rex::C...s::Cron(3pm)
π Rex::Commands::Cron(3pm) β the group chat version π
okay so bestie, welcome to Rex::C...s::Cron(3pm) (yes that's the truncated man-page name, iconic of it honestly), which lives in the User Contributed Perl Documentation corner of the internet. pull up a chair. πͺ
β¨ NAME β¨
Rex::Commands::Cron β Simple Cron Management π
that's it. that's the whole vibe. your cronjobs, but managed, but make it Rex.
πΈ DESCRIPTION πΈ
With this Module you can manage your cronjobs. π
that's the tea, fr fr. cronjobs = handled. no cap.
π¦ SYNOPSIS π¦
here's the sneak peek, the trailer, the little taste π:
use Rex::Commands::Cron;
cron add => "root", {
minute => '5',
hour => '*',
day_of_month => '*',
month => '*',
day_of_week => '*',
command => '/path/to/your/cronjob',
};
cron list => "root";
cron delete => "root", 3;
see how clean that is?? adding, listing, deleting. three little moves. slay. β¨
π EXPORTED FUNCTIONS π
π§ cron_entry($name, %option)
Manage cron entries. that's the whole job description bestie.
here's what it looks like when you're adding one:
cron_entry "reload-httpd",
ensure => "present",
command => "/etc/init.d/httpd restart",
minute => "1,5",
hour => "11,23",
month => "1,5",
day_of_week => "1,3",
day_of_month => "1,3,5",
user => "root",
on_change => sub { say "cron added"; };
and here's the same energy but for removing it:
# remove an entry
cron_entry "reload-httpd",
ensure => "absent",
command => "/etc/init.d/httpd restart",
minute => "1,5",
hour => "11,23",
month => "1,5",
day_of_week => "1,3",
day_of_month => "1,3,5",
user => "root",
on_change => sub { say "cron removed."; };
ngl the ensure => "absent" one is giving reverse-card energy. same entry, same fields, just gone now. π
π cron($action => $user, ...)
With this function you can manage cronjobs. periodt.
Listing cronjobs π
use Rex::Commands::Cron;
use Data::Dumper;
task "listcron", "server1", sub {
my @crons = cron list => "root";
print Dumper(\@crons);
};
you get them all back in an array and you dump them. iconic. πβ¨
Adding a cronjob β¨
This example will add a cronjob running on minute 1, 5, 19 and 40. Every hour and every day.
use Rex::Commands::Cron;
use Data::Dumper;
task "addcron", "server1", sub {
cron add => "root", {
minute => "1,5,19,40",
command => '/path/to/your/cronjob',
};
};
look at that. every hour, every day, at minutes 1, 5, 19 and 40. she's punctual, she's dependable, she's a cronjob. π«Ά
okay and now for the fancy one β this example will add a cronjob running on the 1st, 3rd and 5th day of January and May, but only when it's a Monday or Wednesday. On those days, the job will run when the hour is 11 or 23, and the minute is 1 or 5 (in other words at 11:01, 11:05, 23:01 and 23:05).
task "addcron", "server1", sub {
cron add => "root", {
minute => "1,5",
hour => "11,23",
month => "1,5",
day_of_week => "1,3",
day_of_month => "1,3,5",
command => '/path/to/your/cronjob',
};
};
the way that this one is specific... she knows exactly when she wants to run and honestly? respect. π 11:01, 11:05, 23:01, 23:05 β four little moments, only in January and May, only Mon/Wed. picky queen. π
Deleting a cronjob π
This example will delete the 4th cronjob. Counting starts with zero (0).
task "delcron", "server1", sub {
cron delete => "root", 3;
};
careful bestie: index 3 is the 4th one because counting starts with zero (0). zero-indexed brain required. π
Managing Environment Variables inside cron π
yes you can carry env vars into cron land, watch:
task "mycron", "server1", sub {
cron env => user => add => {
MYVAR => "foo",
};
cron env => user => delete => $index;
cron env => user => delete => 1;
cron env => user => "list";
};
adding, deleting by index, deleting by literal 1, and listing. all of it. env var main character energy. β
π SEE ALSO π
nothing listed here in the original bestie, soβ¦ nothing to see. just you and your crons. π¦
that's the whole page, and for the record, this one shipped with perl v5.40.1 and got written down on 2025-10-03, under the tiny truncated name Rex::C...s::Cron(3pm). bye bestie, go schedule something πβ¨
π¦ where this page comes from
- ubuntu resolute: rex 1.16.1-1 Β· Apache-2.0
- ubuntu stonking: rex 1.16.1-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms