File: README

package info (click to toggle)
libschedule-cron-perl 0.03-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 124 kB
  • ctags: 21
  • sloc: perl: 665; makefile: 40
file content (160 lines) | stat: -rw-r--r-- 5,389 bytes parent folder | download
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
156
157
158
159
160
			    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. (Honestly,
I don't yet know, whether the  Win32 Port provides this system call. I
dare that this is the case). This might change in the future.

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

Schedule::Cron was tested on a Redhat Linux-Box, but it should work on
any UNIX  Box (still  to be  tested). In depends  on some  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

So at  the moment, it probably  won't run on any  'foreign' ports like
the Win32- or MacOs-Port.

These restrictions might be relaxed in the future.

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

As usual:

   perl Makefile.PL
   make
   make test
   make install

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

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

This module  is still in alpha  stage, so I expect  probably some bugs
showing  up. I.e.  the  calculation of  the next  execution time  of a
specific  crontab  entry  might  fail in  some  obscure  circumstances
(though I did what I could to test it thoroughly).

If  you  meet  a bug  (say  hello  to  it  ;-),  please report  it  to
roland@consol.de with  a subject like  "Schedule::Cron Bug-Report". 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.

CREDITS
-------

Thanx to

  Peter Vary 
  Bray Jones 

for submitting bug reports.

COPYRIGHT
---------

Copyright 1999,2000 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@consol.de