-
Notifications
You must be signed in to change notification settings - Fork 0
/
taskmaster.pl
executable file
·46 lines (37 loc) · 1.31 KB
/
taskmaster.pl
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
#!/usr/bin/perl -w
use strict;
my %TASKS = ("nejm.xml" => "/home/ayl/iphone/rss/server/pubmed/nejm.pl", "lancet.xml" => "/home/ayl/iphone/rss/server/pubmed/lancet.pl", "jama.xml" => "/home/ayl/iphone/rss/server/pubmed/jama.pl", "ophtho.xml" => "/home/ayl/iphone/rss/server/pubmed/ophthalmology.pl", "ajo.xml" => "/home/ayl/iphone/rss/server/pubmed/ajo.pl", "archivesOphtho.xml" => "/home/ayl/iphone/rss/server/pubmed/archivesOphtho.pl");
my @undone = keys %TASKS;
my $publishdir = "/home/ayl/public_html/medicalReader";
my $date = `date`;
chomp $date;
print "-----$date-----\n";
$date =~ s/\s//g;
$date =~ s/:/./g;
foreach my $task (@undone) {
unlink $task;
}
while ($#undone > -1) {
for (my $i = 0; $i <= $#undone; $i++) {
my $task = $undone[$i];
`$TASKS{$task} 2>&1 1> /dev/null`;
if (-e $task) {
my $lines = `tail -n 1 $task`;
chomp $lines;
if ($lines =~ m/<\/data>/) {
print "$task finished!\n";
delete($undone[$i]);
} else {
print "$task FAILED: $lines\n";
}
}
if ($#undone != -1) {
sleep 10;
}
}
}
foreach my $task (keys %TASKS) {
#`cp -f $task $publishdir`;
#`mv -f $task $publishdir/$task.$date`;
`mv -f $task $publishdir/$task`;
}