minit

A small yet feature-complete init (http://fefe.de/minit/)
Log | Files | Refs | README | LICENSE

ftrigger.1 (1798B)


      1 .TH ftrigger 1
      2 .SH NAME
      3 ftrigger \- trigger an action if a file changes
      4 .SH SYNOPSIS
      5 .B ftrigger [-v] @command filename [@command filename...]
      6 
      7 .SH DESCRIPTION
      8 .B ftrigger
      9 can watch a list of files and run shell commands if they change.
     10 
     11 .B ftrigger
     12 uses the inotify kernel notification mechanism, so it triggers in real
     13 time.  ftrigger will trigger when the file is closed after it was opened
     14 for writing to avoid race conditions when the file is not fully written.
     15 
     16 .SH EXAMPLES
     17 
     18 % ftrigger '@msvc -h sshd' /etc/sshd_config
     19 
     20 This will watch /etc/sshd_config, and if it changes, msvc will send a
     21 SIGHUP to the sshd service.
     22 
     23 It is also possible to watch more than one file at a time:
     24 
     25 % ftrigger '@echo updated' /tmp/a /tmp/b
     26 
     27 And it is possible to watch multiple files with different triggers:
     28 
     29 % ftrigger '@echo a updated' /tmp/a '@echo b updated' /tmp/b
     30 
     31 .SH "RACE CONDITION"
     32 
     33 The inotify API has an inherent race condition.  ftrigger has to watch
     34 both the file and the directory it is in for changes.  If the file is
     35 newly created, ftrigger will receive a notification via the directory,
     36 and will then add a watch to the newly created file, to get notified if
     37 somebody closes the file who had it open for writing.
     38 
     39 If the other process closes the file before ftrigger has a chance to add
     40 the watch on the file, ftrigger will never get notified.  In practice, I
     41 have only seen this happen with touch, where the open(3) is immediately
     42 followed by the close(3), and there is no write(3) in the middle.
     43 
     44 To work around this race, ftrigger will also watch for modify events for
     45 the file, and if there aren't any within a second, it will assume the
     46 race happened and trigger on the file.
     47 
     48 .SH AUTHOR
     49 ftrigger was written by Felix von Leitner and can be downloaded from
     50 .I http://www.fefe.de/minit/
     51