#!/usr/bin/microperl
 
my $sec2log = 600;
 
while (1) {
 
########## Gps log rotate ###########
 
open(GPS, "/gps.log");
my @gps = <GPS>;
close(FILE);
 
my $togz;
my $tolog;
 
my $time = time();
 
foreach my $line (@gps) {
  my @split = split(/\|/, $line);
  $split[1] =~ s/ //g;
  if (($time - $split[1]) > $sec2log) {
    $togz .= $line;
  } else {
    $tolog .= $line;
  }
}
 
if ($togz) {
  open(FILE, ">/root/logs/gps-$time.log");
  print FILE $togz;
  close(FILE);
 
  `gzip /root/logs/gps-$time.log`;
}
 
open(FILE, ">/gps.log");
print FILE $tolog;
close(FILE);
 
 
########## End ###########
sleep($sec2log);
}
 
missions/haps/gpslogrotate.pl.txt · Last modified: 2008/05/03 23:22 by jamescoxon
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki