Помогите разобраться в чем проблема.
Код: Выделить всё
#!/usr/bin/perl
use DBI;
use POSIX qw(strftime);
############# the number of messages in queue ##############
system ("mailq | grep 'Requests.' > /home/karpoveg/test_prog/123txt");
system ("mailq >123txt");
open(LOGFILE, "/home/karpoveg/test_prog/123txt");
@logbuffer = <LOGFILE>;
close(LOGFILE) || die "Error closing local log file: $!";
system ("rm 123txt");
print $formatted;
foreach my $line (@logbuffer)
{
if ($line =~ m/in (\d*) Requests./g)
{
$asd=$1;
}
}
print "\n$asd\n";
############## Cheking the number of leters ##################################
if ($asd > 15)
{
open( LOGFILE1, "<data");
@logbuffer1 = <LOGFILE1>;
close(LOGFILE1) || die "Error closing local log file: $!";
foreach my $line1 (@logbuffer1)
{
if ($line1 =~ m/(\d*)/g)
{
$qwe=$1;
}
}
if( $qwe>0)
{
$qwe++;
$res="num $qwe";
system("echo $qwe >data");
}
else
{
$res="first";
system("echo 1 >data");
}
}
else
{
$res="ok";
system("echo 0 >data");
}
############# Date Time ###################
my $today = time;
my $formatted = strftime "%b-%e-%H:%M", ( localtime($today) );
############## Collecting statistics in the database ###############
#$dbh = DBI->connect('DBI:mysql:maillogs:127.0.0.1',*****','*****'');
#$query="INSERT INTO mailq VALUE ('$asd','$formatted','$res')";
#$sth = $dbh->prepare($query);
#$sth->execute;
#$rc = $sth->finish;
#$rc = $dbh->disconnect;
*/5 * * * * root /home/123.pl (пример)
Срабатывания происходят.