Skip to content

Navigation Menu

Sign in
Sign up

random minute is not working as expected #1658

davidmoreirafr started this conversation in Potential issues
Discussion options

Describe your experience

When trying to add the following cron table entries with the code example, the first entry is deleted by the second entry.

~ seems to not behave properly if placed as a minute.

Expected behavior

crontab -l should return

~ * * * * -ns sleep 0
~ * * * * -ns sleep 1

I had the following:

~ * * * * -ns sleep 1

How to reproduce it

Run the code example in a task.

Code example

desc "..";
task 'cron_bug', group => 'all', sub {
 cron add => "root", {
 minute => "~",
 command => "-ns sleep 0"
 };
 cron add => "root", {
 minute => "~",
 command => "-ns sleep 1"
 };
};

Additional context

Had to fix the file `usr/local/libdata/perl5/site_perl/Rex/Cron/FreeBSD.pm with the patch

diff -u /usr/local/libdata/perl5/site_perl/Rex/Cron/FreeBSD.pm\~ /usr/local/libdata/perl5/site_perl/Rex/Cron/FreeBSD.pm 
--- /usr/local/libdata/perl5/site_perl/Rex/Cron/FreeBSD.pm~ Sat Aug 5 21:34:38 2023 
+++ /usr/local/libdata/perl5/site_perl/Rex/Cron/FreeBSD.pm Sun Mar 1 06:59:00 2026 
@@ -33,7 +33,7 @@ 
 
 my $command = '( crontab -l'; 
 $command .= " -u $user" if defined $user; 
- $command .= " >$tmp_file ) >& /dev/null ; cat $tmp_file ; rm $tmp_file"; 
+ $command .= " >$tmp_file ) 2> /dev/null ; cat $tmp_file ; rm $tmp_file"; 
 
 my @lines = i_run $command; 
 $self->parse_cron(@lines); 

The issue seems to be the ~ as a minute, it's running as expected with when using the following:

  • minute => "0"
  • hour => "~"

Rex version

(R)?ex 1.14.3

Installation method

package manager

Perl version

This is perl 5, version 40, subversion 1 (v5.40.1) built for amd64-openbsd

Operating system running rex

OpenBSD 7.8

Operating system managed by rex

OpenBSD 7.8

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage needed A potential bug that needs to be reproduced and understood
1 participant

AltStyle によって変換されたページ (->オリジナル) /