Heray-Was-Here
Server : Apache
System : Linux vps103298.mylogin.co 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User : calvet ( 273824)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /usr/share/doc/perl-Schedule-Cron/examples/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/doc/perl-Schedule-Cron/examples/simple.pl
#!/usr/bin/perl

# Very simple examples which print the current 
# time every 10 Minutes.
#
# The purpose is to show a common usage pattern 
# using a single dispatcher subroutine provided
# at construction time

use lib "../lib";
use Schedule::Cron;

# Create new object with default dispatcher
my $cron = new Schedule::Cron(\&dispatcher);

# The cron entry which fires every 10 minutes
my $entry = "0-59/5 * * * *";

# Dispatcher subroutine called from cron
sub dispatcher { 
    open(T,">>timestamps.txt");
    print T "Current: ",scalar(localtime),"\n";
    print T "Next:    ",scalar(localtime($cron->get_next_execution_time($entry))),"\n";
    close T;
    sleep(30);
}


# Call &dispatcher() every ten minutes
$cron->add_entry($entry);

# Run scheduler and block. 'nofork' forces the subroutine to 
# be called in the main process
$cron->run(nofork=>1);

Hry