Files needed by the scheduler
[koha.git] / C4 / Scheduler.pm
1 package C4::Scheduler;
2
3 # Copyright 2007 Liblime Ltd
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
11 #
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA  02111-1307 USA
19
20 use strict;
21 require Exporter;
22
23 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
24 use C4::Context;
25 use Smart::Comments;
26 use Schedule::At;
27 # set the version for version checking
28 $VERSION = 0.01;
29
30 @ISA = qw(Exporter);
31 @EXPORT =
32   qw(get_jobs get_job add_job remove_job);
33
34 =head1 NAME
35
36 C4::Scheduler - Module for running jobs with the unix at command
37
38 =head1 SYNOPSIS
39
40   use C4::Scheduler;
41
42 =head1 DESCRIPTION
43
44
45 =head1 METHODS
46
47 =over 2
48
49 =cut
50
51 =item get_jobs();
52
53 This will return all scheduled jobs
54
55 =cut
56
57 sub get_jobs {
58         my %jobs = Schedule::At::getJobs();
59         return (\%jobs);
60 }
61
62 =item get_job($id)
63
64 This will return the job with the given id
65
66 =cut
67
68 sub get_job {
69         my ($id)=@_;
70         my %jobs = chedule::At::getJobs(JOBID => $id);
71 }
72
73 =item add_job ($time,$command)
74
75 Given a timestamp and a command this will schedule the job to run at that time
76
77 =cut
78
79 sub add_job {
80         my ($time,$command) = @_;
81         Schedule::At::add(TIME => $time, COMMAND => $command, TAG => $command);
82 }
83
84 sub remove_job {
85         my ($jobid)=@_;
86         Schedule::At::remove(JOBID => $jobid);
87 }
88
89 =head1 AUTHOR
90
91 Chris Cormack <crc@liblime.com>
92
93 =cut
94
95 1;