File: README

package info (click to toggle)
libschedule-cron-perl 1.01-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 324 kB
  • ctags: 73
  • sloc: perl: 1,781; makefile: 6
file content (155 lines) | stat: -rw-r--r-- 5,412 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
			    Schedule::Cron
			    ==============

This module provides  a simple but complete cron  like scheduler.  I.e
this modules can be  used for periodically executing Perl subroutines.
The  dates  and  parameters  for  the subroutines  to  be  called  are
specified with a format known as crontab entry (see manpage crontab(5)
or documentation of Schedule::Cron).

The   philosophy  behind   Schedule::Cron  is   to   call  subroutines
periodically from  within one single  Perl program instead  of letting
cron  trigger several  (possibly different)  Perl  scripts. Everything
under  one  roof.  Furthermore  Schedule::Cron  provides mechanism  to
create crontab entries dynamically, which isn't that easy with cron.

Schedule::Cron  knows  about  all   extensions  (well,  at  least  all
extensions I'm aware of, i.e those  of the so called "Vixie" cron) for
crontab entries like ranges  including 'steps', specification of month
and days of the week by name or coexistence of lists and ranges in the
same field. And  even a bit more (like lists  and ranges with symbolic
names).

This module is rather effective concerning system load.  It calculates
the execution  dates in advance and  will sleep until  those dates are
reached (and  wont wake  up every minute  to check for  execution like
cron).   However, it  relies on  the accuracy  of your  sleep() system
call.

EXAMPLES
--------

 * Minimalistic:

      use Schedule::Cron;

      my $dispatcher = sub { print "Time to start...\n"};
      my $cron = new Schedule::Cron($dispatcher);	 

      $cron->add_entry("0 7 * * *");
      $cron->run;             # Runs forever...

 * A bit more complex:

      use Schedule::Cron;

      my $cron = new Schedule::Cron(  sub { print "@_","\n" },
                                      file  => "check_links.sched",
                                      eval  => 1);

      sub check_links { 
        my $args = shift;
        print "URL:   ",$args->{url},"\n";
        print "Depth: ",$args->{depth},"\n";
      } 

      $cron->add_entry("0-40/5,55 3,22 * Jan-Nov Fri",
                       { sub  => \&check_links,
                         args => [ { url   => "http://www.consol.de", 
                                     depth => 2 } ],
                         eval => 0 });
      # ... add more ....
      $cron->run(detach=>1,pid_file=>"/var/run/checker.pid");
      # ... continue ...

 * simple cron replacement (for a single crontab file):
   
      use Schedule::Cron;
      my $cron = new Schedule::Cron(sub { system(shift) },
                                    file => "/var/spool/crontab.perl");
      $cron->run();
      
PREREQUISITES
-------------

In order  to install and use  this package you will  need Perl version
5.005  or better.   Furthermore  you need  the module  Time::ParseDate
(contained in the Time-modules-xx.xxxxx) available on CPAN.

You need a fork()-aware Perl for dispatching the cron jobs. This might
change in the future. On systems  without a fork() system call you can
use the 'nofork' option to run your jobs within the current process.

OS-DEPENDENCIES
---------------

Schedule::Cron was tested on a Redhat Linux-Box, but it should work on
any UNIX Box.  In depends on some original UNIX system calls for
starting jobs and detaching itself to the background:

  * It uses fork() for starting jobs
  * For  detaching it  uses either  setsid (POSIX)  or the  ioctl call
    TIOCNOTTY

The roadmap  include plans  for porting the  fork mechanism over  to a
thread based scheme, which should make dynamic update much easier.

If the  system calls mentioned  above are not available  (which should
hapen nowadays only  under rare circumstances), you can  still use the
'nofork' option to run all jobs within a single process/thread. Please
refer to the documentation for further reading.

INSTALLATION
------------

Installation can be don either in the old fashioned way

   perl Makefile.PL
   make
   make test
   make install

or alternatively with Module::Build

   perl Build.PL
   ./Build 
   ./Build test
   ./Build install

See the  documentation for  Schedule::Cron for a  detailed description
and further usage examples.

REPORTING BUGS
--------------

If  you  meet  a  bug  (say   hello  to  it  ;-),  open  a  ticket  at
https://rt.cpan.org/Ticket/Create.html?Queue=Schedule-Cron.          

In addition of  a problem description, please add  a short description
of you  OS, your Perl version  and the version  of Time::ParseDate you
are using.  If some of the  provided tests fail, include the output of
'make test TEST_VERBOSE=1' as well.

If you suspect,  that the date calculation of  the next execution time
is buggy, please  use the following interactive command  to generate a
bug report.

   perl -MSchedule::Cron -e 'bug Schedule::Cron'

You will be asked for a  reference time (default: the current time), a
crontab  date  pattern  (with  five  columns) and  the  expected  next
execution date  (relative to  the reference time).   The dates  can be
specified in  a format understood by  'parsedate' from Time::ParseDate
(like 'now  + 5  days').  Please include  the output of  this command.

LICENSE
-------

Copyright 1999-2011 Roland Huss.

This library is  free software; you can redistribute  it and/or modify
it under the same terms as Perl itself.

Enjoy it...
                                            ...roland (roland@cpan.org)