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

NAME

4     entr — run arbitrary commands when files change
5

SYNOPSIS

7     entr [-acdnprsz] 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      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

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     If the -z flag is set and the utility is successfully executed, the sta‐
77     tus of the child process is returned.  Otherwise entr normally returns
78     one of the following values:
79
80           0       Normal termination after receiving SIGINT
81           1       No regular files were provided as input or an error
82                   occurred
83           2       A file was added to a directory and the directory watch
84                   option was specified
85

EXAMPLES

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