#! /usr/bin/perl use strict; use warnings ; use diagnostics ; sub schedule (&@) { my ( $condition, $exec_stmt ) = @_ ; if ( &{$condition} ) { my $pid = fork() ; if ( !$pid ) { exec( $exec_stmt ) ; } } } while ( 1 ) { my ( $min, $hour, $mday, $mon, $year, $wday ) = ( localtime )[1..6] ; $year += 1900 ; # Run everyday at 12:00 schedule { $hour == 12 && $min == 00 } '/usr/bin/some/prog' ; # Run every three hours schedule { $hour % 3 == 0 } '/usr/sbin/some/other/prog' ; # Every Tuesday, plus the 1st & 15th of every month at midnight. schedule { ( $hour == 0 && $min == 0 ) && ( ( $wday == 2 ) || ( $mday == 1 || $mday == 15 ) ) } '/usr/local/bin/yet/another/prog' ; sleep 60 ; }