I've written a script that monitors a number of directories for changes in file modification times. It goes something like this:
#! /usr/bin/perl
use strict;
use warnings;
my @directories = qw{/foo /bar};
my $directory;
my @files;
while ( 1 ) {
FILECHECK:
foreach $directory ( @directories ) {
@files = glob("${directory}/*.log");
next FILECHECK unless @files;
do some stuff here...
}
sleep 30;
}
Obviously, the script runs indefinitely and I need to keep it running after I logout of my shell. With shell scripts, I typically use nohup and put the pid in the background (&), but I was wondering if there are any other ways to do it?