3
3
# bin/GenericAgent.pl - a generic agent -=> e. g. close ale emails in a specific queue
4
4
# Copyright (C) 2001-2008 OTRS AG, http://otrs.org/
6
# $Id: GenericAgent.pl,v 1.49 2008/05/08 09:36:57 mh Exp $
6
# $Id: GenericAgent.pl,v 1.50 2008/09/08 06:48:58 martin Exp $
8
8
# This program is free software; you can redistribute it and/or modify
9
9
# it under the terms of the GNU General Public License as published by
123
123
# process all jobs
124
124
my %DBJobs = $CommonObject{GenericAgentObject}->JobList();
125
125
for my $DBJob ( sort keys %DBJobs ) {
126
127
my %DBJobRaw = $CommonObject{GenericAgentObject}->JobGet( Name => $DBJob );
129
# check requred params (need min. one param)
131
for my $Key (qw( ScheduleDays ScheduleMinutes ScheduleHours ) ) {
132
if ( $DBJobRaw{$Key} ) {
138
# next if jobs is invalid
139
next if !$DBJobRaw{Valid};
141
# get time params to check last and current run
131
142
my ( $Sec, $Min, $Hour, $Day, $Month, $Year, $WDay )
132
143
= $CommonObject{TimeObject}->SystemTime2Date(
133
144
SystemTime => $CommonObject{TimeObject}->SystemTime(),
136
146
if ( $Min =~ /(.)./ ) {
139
151
if ( $DBJobRaw{ScheduleDays} ) {
141
153
for ( @{ $DBJobRaw{ScheduleDays} } ) {
142
154
if ( $_ eq $WDay ) {
151
if ( !defined $DBJobRaw{ScheduleMinutes} ) {
152
@{ $DBJobRaw{ScheduleMinutes} } = qw(00 10 20 30 40 50);
155
for ( @{ $DBJobRaw{ScheduleMinutes} } ) {
164
if ( !defined $DBJobRaw{ScheduleHours} ) {
165
@{ $DBJobRaw{ScheduleHours} }
166
= qw(00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23);
169
for ( @{ $DBJobRaw{ScheduleHours} } ) {
179
# check if job is invalid
180
if ( !$DBJobRaw{Valid} ) {
161
# check ScheduleMinutes
162
if ( $DBJobRaw{ScheduleMinutes} ) {
164
for ( @{ $DBJobRaw{ScheduleMinutes} } ) {
172
# check ScheduleHours
173
if ( $DBJobRaw{ScheduleHours} ) {
175
for ( @{ $DBJobRaw{ScheduleHours} } ) {
184
183
# check if job already was running
191
190
print "Job '$DBJob' already finished!\n";
197
$CommonObject{GenericAgentObject}->JobRun(
200
UserID => $UserIDOfGenericAgent,
195
$CommonObject{GenericAgentObject}->JobRun(
198
UserID => $UserIDOfGenericAgent,
205
202
# delete pid lock