Hello,

I have a perl script that is to stop and start at midnight, and write to a new log 
file. 

The problem is it runs once then does not run again?? 

Below is the script that I am tring to use?? 


bash-2.03#
#!/bin/perl -w
use warnings;
use strict;
 
my ( $sec, $min, $hour, $day, $mon, $year ) = localtime;
my $snoop   = '/usr/sbin/snoop -d ge0 -ta';
my $date = `date +%W`;
chop($date);
my $dir = "/var/weeks/03_week_$date";

my $logfile = sprintf '/var/weeks/03_week_%d/%02d%02d%02d%02d%02d.sno',
    `date +%W`, $year % 100, $mon + 1, $day, $hour, $min;
 
# create 03_week_dir if does not exist
unless(-d $dir){
mkdir $dir,0660;
} 
 
open LOG, '>', $logfile or die "Cannot open $logfile: $!";
# set default output filehandle and autoflush
select LOG;
$| = 1;
 
print '===============' . localtime . " ==================\n\n";
 
open SNOOP, "$snoop |" or die "Cannot open pipe from $snoop: $!";
 
while ( <SNOOP> ) {
    print;
    # restart this process if midnight
    ( $sec, $min, $hour ) = localtime;
    exec $0 if $sec + $min + $hour == 0;
    }
bash-2.03# 

Thanks,
RM

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to