use::warnings; use::strict; my $rmthost = 'backupserver'; my $rmtuser = 'anonymous'; my $rmtpath = 'tempdir'; my $lclpath = '/home/user/testdir'; my $lclglob = '*.txt'; my $flagfile = '.last_backup'; my $r_opts = "'ssh -l $rmthost $rmtuser'"; my $lclfiles = "$lclpath/$lclglob"; sub modtime { my $file = shift; my @stats = stat $file or return 0; return $stats[9]; } while (1) { my $timestamp = modtime("$lclpath/$flagfile"); my $run = grep {modtime($_) > $timestamp} glob $lclfiles; if ($run) { system "scp $r_opts $lclfiles $rmthost:$rmtpath"; open FLAG, ">$lclpath/$flagfile" or die; close FLAG or die; } sleep 60; }