1ENTR(1)                   BSD General Commands Manual                  ENTR(1)
2

NAME

4     entr — run arbitrary commands when files change
5

SYNOPSIS

7     entr [-acdprs] utility [argument /_ ...]
8

DESCRIPTION

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      Execute /usr/bin/clear before invoking the utility specified on
24             the command line.
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

COMMANDS

60     entr listens for keyboard input and responds to the following commands:
61
62space⟩  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

ENVIRONMENT

69     If PAGER is undefined, entr will assign /bin/cat to prevent interactive
70     utilities from waiting for keyboard input if output does not fit on the
71     screen.
72
73     If SHELL is undefined, entr will use /bin/sh.
74

EXIT STATUS

76     The entr utility exits with one of the following values:
77
78           0       Normal termination after receiving SIGINT or the -z flag
79                   was set and the utility was executed successfully
80           1       No regular files were provided as input or an error
81                   occurred
82           2       A file was added to a directory and the directory watch
83                   option was specified
84

EXAMPLES

86     Rebuild a project if source files change, limiting output to the first 20
87     lines:
88
89           $ find src/ | entr -s 'make | sed 20q'
90
91     Launch and auto-reload a node.js server:
92
93           $ ls *.js | entr -r node app.js
94
95     Clear the screen and run a query after the SQL script is updated:
96
97           $ echo my.sql | entr -cp psql -f /_
98
99     Rebuild project if a source file is modified or added to the src/ direc‐
100     tory:
101
102           $ while true; do ls src/*.rb | entr -d make; done
103
104     Auto-reload a web server, or terminate if the server exits
105
106           $ ls * | entr -rz ./httpd
107
108BSD                             April 17, 2020                             BSD
Impressum