Thread Perlscript für Cronjob Abfolge (9 answers)
Opened by Channel at 2007-04-02 16:05

renee
 2007-04-02 17:48
#9872 #9872
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Probier mal:
Code: (dl )
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
#!/usr/bin/perl

use strict;
use warnings;
use CGI qw/:cgi-lib :standard/;
use CGI::Carp qw(fatalsToBrowser);

print header;

#Instructions
##################

#Set this to the server path to the crons.txt
my $pathtocrontxt="./cron.txt";
# In the crons.txt put the first line as 0 and then put each cronjob on a seperate line below
# set the chmod permissions to crons.txt to 777 and cron.cgi to 755

my @commands;
my $lines = 0;
#####################################
print "Running Crons...\n";
if( open my $inf,"<",$pathtocrontxt ){
@commands = <$inf>;
close $inf;
chomp @commands;

for my $line(@commands){
if( $lines == 0 && $commands[$lines] == 0 ){
print "not working\n";
$commands[0] = 1;
write_file();
}
elsif($lines == 0 && $commands[$lines] == 1){
print "working\n";
$commands[0] = 0;
write_file();
exit;
}
else {
print "Executing: $line\n";
my $output = system("$line");
print "$output\n";
}

$lines++;
}

$commands[0] = 0;
}

print "\n\nDone!\n";

sub write_file{
if( open my $out, '>', $pathtocrontxt ){
print $out $_,"\n" for @commands;
}
}
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread Perlscript für Cronjob Abfolge