1ENTR(1) BSD General Commands Manual ENTR(1)
2
4 entr — run arbitrary commands when files change
5
7 entr [-acdnprsz] utility [argument /_ ...]
8
10 A list of files provided on standard input, and the utility is executed
11 using the supplied arguments if any of them change. entr waits for the
12 child process to finish before responding to subsequent file system
13 events. A TTY is also opened before entering the watch loop in order to
14 support interactive utilities.
15
16 The arguments are as follows:
17
18 -a Respond to all events which occur while the utility is running.
19 Without this option, entr consolidates events in order to avoid
20 looping. This option has no effect in conjunction with the -r
21 flag.
22
23 -c Clear the screen before invoking the utility specified on the
24 command line. Specify twice to erase the scrollback buffer.
25
26 -d Track the directories of regular files provided as input and exit
27 if a new file is added. This option also enables directories to
28 be specified explicitly. Files with names beginning with ‘.’ are
29 ignored.
30
31 -n Run in non-interactive mode. In this mode entr does not attempt
32 to read from the TTY or change its properties.
33
34 -p Postpone the first execution of the utility until a file is modi‐
35 fied.
36
37 -r Reload a persistent child process. As with the standard mode of
38 operation, a utility which terminates is not executed again until
39 a file system or keyboard event is processed. SIGTERM is used to
40 terminate the utility before it is restarted. A process group is
41 created to prevent shell scripts from masking signals. entr
42 waits for the utility to exit to ensure that resources such as
43 sockets have been closed. Control of the TTY is not transferred
44 to the child process.
45
46 -s Evaluate the first argument using the interpreter specified by
47 the SHELL environment variable. If standard output is a TTY, the
48 name of the shell and exit code is printed after each invocation.
49
50 -z Exit after the utility completes. When combined with -r the
51 utility will be restarted again only in response to commands or
52 file system events.
53
54 The first argument named /_ is replaced with the absolute path of the
55 first file to trigger an event. The first file under watch is used as
56 the default. If the -s option is used, the name of the first file to
57 trigger an event can be read from $0.
58
60 entr listens for keyboard input and responds to the following commands:
61
62 ⟨space⟩ Execute the utility immediately. If the -r option is set this
63 will terminate and restart the child process as if a file change
64 event had occurred.
65
66 q Quit; equivalent pressing ⟨control-C⟩.
67
69 PAGER Set to /bin/cat by default to prevent interactive utilities
70 from waiting for keyboard input if output does not fit on
71 the screen.
72
73 SHELL Specify the shell to use with the -s flag. The default is
74 /bin/sh.
75
76 EV_TRACE Print file system event messages.
77
79 If the -z flag is set and the utility is successfully executed, the sta‐
80 tus of the child process is returned. Otherwise entr normally returns
81 one of the following values:
82
83 0 Normal termination after receiving SIGINT
84 1 No regular files were provided as input or an error oc‐
85 curred
86 2 A file was added to a directory and the directory watch op‐
87 tion was specified
88
90 Rebuild a project if source files change, limiting output to the first 20
91 lines:
92
93 $ find src/ | entr -s 'make | sed 20q'
94
95 Launch and auto-reload a node.js server:
96
97 $ ls *.js | entr -r node app.js
98
99 Clear the screen and run a query after the SQL script is updated:
100
101 $ echo my.sql | entr -cp psql -f /_
102
103 Rebuild project if a source file is modified or added to the src/ direc‐
104 tory:
105
106 $ while sleep 0.1; do ls src/*.rb | entr -d make; done
107
108 Auto-reload a web server, or terminate if the server exits
109
110 $ ls * | entr -rz ./httpd
111
112BSD July 2, 2021 BSD