I wrote this up years ago, and have a side screen full of little fun console windows counting down to their jobs, with FG/BG colors set based on topic. Using your task scheduler would be better if you want it to be more reliable than entertaining however.

In scripts:
sleepUntil( nextTimeOccurence({time=>'3:15', weekdays=>'MTWRF'}), sub {printf"%s - Next telemetry pull in %s.\r", scalar loc +altime, englishTime(shift)} ); print "\n";
In tools.pm:
sub sleepUntil { my $time = shift; my $sub = shift; my $snooze = shift // 2; while (time < $time) { $sub->($time - time) if ref $sub eq 'CODE'; sleep $snooze; } } sub nextTimeOccurence { my $settings = shift; my $wantedSeconds = 0; if ($settings->{time} =~ /([0-9]+):([0-9]{2})/i) { $wantedSeconds = ($1*60 + $2)*60; } my @skipWeekDays; if ($settings->{weekdays} =~ /[mtwrfau]/i) { @skipWeekDays = qw( u m t w r f a ); #Sunday is day 0 of the w +eek for localtime for (0..$#skipWeekDays) { $skipWeekDays[$_] = 0 if $settings->{weekdays} =~ /$skipWe +ekDays[$_]/i; } } my $now = time; my ($sec, $min, $hour, $wday) = (localtime($now))[0,1,2,6]; my $todaysNow = ($hour*60+$min)*60+$sec; $sec += $min*60 + $hour *3600; #seconds elapsed today my $desiredTime = $now - $sec + $wantedSeconds; #today's time of d +ay if ($todaysNow > $wantedSeconds) #next desired time will occur tom +orrow. { $desiredTime += 24*60*60; $wday++; $wday %= 7; } while ($skipWeekDays[$wday]) { $desiredTime += 24*60*60; $wday++; $wday %= 7; } return $desiredTime; #Process over lunch hour or whatever } sub englishTime { my $time = shift; return "$time second".($time==1?'':'s') if ($time < 90); $time = int($time/60); return "$time minute".($time==1?'':'s') if ($time < 90); $time = int($time/60); return "$time hour".($time==1?'':'s') if ($time < 36); $time = int($time/24); return "$time day".($time==1?'':'s'); }

In reply to Re: Scheduling a shell script to run every wednesday at 10 AM with perl without cron by SuicideJunkie
in thread Scheduling a shell script to run every wednesday at 10 AM with perl without cron by kshitij

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.