in reply to Crontab replacement in Perl

If you have a shell account, you should be able to run crontab -e to edit your user crontab.

Just for reference, here is a low level version to execute one thing at a specific time every day (untested, from memory):

... my $targettimetext = "13:14:15"; # Turn target time into seconds my @tttparts = split/\:/, $targettimetext; my $targettime = ($tttparts[0] * 3600) + ($tttparts[1] * 60) + $tttpar +ts[2]; ... while(1) { # Turn the current time into seconds my ($sec,$min, $hour, $mday,$mon, $year, $wday,$yday, $isdst) = lo +caltime time; my $nowtime = ($hour * 3600) + ($minute * 60) + $sec; # Not yet time to do things? Sleep until it is if($nowtime < $targettime) { sleep($targettime - $nowtime); } # YOUR STUFF HERE # Recalculate the current time after doing stuff ($sec,$min, $hour, $mday,$mon, $year, $wday,$yday, $isdst) = local +time time; $nowtime = ($hour * 3600) + ($minute * 60) + $sec; # Sleep for the rest of the day sleep(86400 - $nowtime); }

Edit: Please be aware, the simplistic approach above doesn't account for all the time calculation weirdness like daylight savings time changes, leap seconds and skipped days. For that, i refer you to this excellent Tom Scott video.

perl -e 'use Crypt::Digest::SHA256 qw[sha256_hex]; print substr(sha256_hex("the Answer To Life, The Universe And Everything"), 6, 2), "\n";'

Replies are listed 'Best First'.
Re^2: Crontab replacement in Perl
by soonix (Chancellor) on Feb 07, 2022 at 20:33 UTC

      True. But on the other hand, that's the same thing people said about data logging, and then went ahead and used Log4J.

      Not to mention that "using code other people wrote to solve complicated problems" means quite a few popular image formats (and a lot of other stuff) uses 32 bit timestamps. Meaning i'll probably just make it to retirement before that particular puppy has a major accident on the IT carpet.

      perl -e 'use Crypt::Digest::SHA256 qw[sha256_hex]; print substr(sha256_hex("the Answer To Life, The Universe And Everything"), 6, 2), "\n";'
        Yes, seen as a possible source of income, 't is too bad the Epochalypse doesn't happen earlier. But don't despair, there are some (probably smaller) Bugs still waiting to be slain in the near future ;-)