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