RE: [loganalysis] stopping/starting swatchn

From: Jason Lewis (jlewisat_private)
Date: Sun Aug 26 2001 - 16:28:57 PDT

  • Next message: Tobia,Paul: "RE: [loganalysis] fwlogwatch feedback"

    How about this one?   It works for me.  I can't find the author or where I
    found it.
    #!/usr/bin/perl
    
    =head1 NAME
    
    reswatch - Restart Swatch
    
    =head1 DESCRIPTION
    
    B<Reswatch> attempts to send a HUP signal to a swatch process. It finds the
    process ID of B<swatch> by looking for a file named I<.swatch_script.>B<PID>
    in the home directory.
    
    =head1 SEE ALSO
    
    b<swatch(1)>
    
    =cut
    
    use DirHandle;
    
    my $script_prefix = '.swatch_script';
    my $homedir = $ENV{'HOME'};
    my $dh = new DirHandle $homedir;
    
    if (defined $dh) {
      while (defined($_ = $dh->read)) {
        if (/^${script_prefix}\.[0-9]*/) {
          split(/\./, $_);;
          print "Sending HUP signal to PID $_[$#_]\n";
          kill('HUP', $_[$#_]);
          undef $dh;
          exit 0;
        }
      }
    }
    undef $dh;
    exit 1;
    
    
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: loganalysis-unsubscribeat_private
    For additional commands, e-mail: loganalysis-helpat_private
    



    This archive was generated by hypermail 2b30 : Mon Aug 27 2001 - 07:48:39 PDT