On Tue, Feb 12, 2002 at 03:01:05PM +0100, Tomás García Ferrari wrote: > > Which should be the best approach to have an FTP server that checkes when > some user upload a file an runs a process after that? Log checking? Adding > this process to a cron job? Which way should I start searching...?
We use cron jobs here since it varies from user to user as to how often a file may be updated - some we check every 5 minutes and others only once or twice per day. When you check for new files being dropped into a directory, you should do a double-check with lsof to see if the file is still open or you could be trying to process a file that is still in transit. My approach is based on the following rough perl code (these are just snippets so you'll need to incorporate them into your own procedure): my $local="[the download directory]"; my @files; sub getfiles() { open(FILES,"find $local -type f |"); while (my $t = <FILES>) { $files[@files] = $t; } close(FILES); } getfiles(); foreach my $t (@files) { chomp ($t) ; if (system("lsof -Fn -- $local/* | grep -q \"n$t\"")) { [do stuff with $t]; } } Cheers, .../Ed -- Ed Wilts, Mounds View, MN, USA mailto:[EMAIL PROTECTED] _______________________________________________ Redhat-list mailing list [EMAIL PROTECTED] https://listman.redhat.com/mailman/listinfo/redhat-list