#!/usr/local/bin/perl -w # Usage: file-watch.pl file_to_watch interval commands_to_run # $Id: file-watch.pl,v 1.1.1.1 2003/06/12 12:20:13 evdb Exp $ use strict; my $file = shift @ARGV; my $SLEEP = shift @ARGV; my @CMD = @ARGV; die "Could not find the file $file.\n" unless -e $file; my $last_mod = (stat($file))[9]; my $self_mod = (stat($0))[9]; while (1) { my $curr_mod = (stat($file))[9]; if ( $curr_mod > $last_mod ) { $last_mod = $curr_mod; system @CMD; } else { sleep $SLEEP; } }