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.  If specified twice, all new entries to
29             a directory are recognized, otherwise files with names beginning
30             with ‘.’ are ignored.
31
32     -n      Run in non-interactive mode.  In this mode entr does not attempt
33             to read from the TTY or change its properties.
34
35     -p      Postpone the first execution of the utility until a file is modi‐
36             fied.
37
38     -r      Reload a persistent child process.  As with the standard mode of
39             operation, a utility which terminates is not executed again until
40             a file system or keyboard event is processed.  SIGTERM is used to
41             terminate the utility before it is restarted.  A process group is
42             created to prevent shell scripts from masking signals.  entr
43             waits for the utility to exit to ensure that resources such as
44             sockets have been closed.  Control of the TTY is not transferred
45             to the child process.
46
47     -s      Evaluate the first argument using the interpreter specified by
48             the SHELL environment variable.  If standard output is a TTY, the
49             name of the shell and exit code is printed after each invocation.
50
51     -z      Exit after the utility completes.  When combined with -r the
52             utility will be restarted again only in response to commands or
53             file system events.
54
55     The first argument named /_ is replaced with the absolute path of the
56     first file to trigger an event.  The first file under watch is used as
57     the default.  If the -s option is used, the name of the first file to
58     trigger an event can be read from $0.
59

COMMANDS

61     entr listens for keyboard input and responds to the following commands:
62
63space⟩  Execute the utility immediately.  If the -r option is set this
64              will terminate and restart the child process as if a file change
65              event had occurred.
66
67     q        Quit; equivalent pressing ⟨control-C⟩.
68

ENVIRONMENT

70     PAGER         Set to /bin/cat by default to prevent interactive utilities
71                   from waiting for keyboard input if output does not fit on
72                   the screen.
73
74     SHELL         Specify the shell to use with the -s flag.  The default is
75                   /bin/sh.
76
77     EV_TRACE      Print file system event messages.
78

EXIT STATUS

80     If the -z flag is set and the utility is successfully executed, the sta‐
81     tus of the child process is returned.  If the child process was termi‐
82     nated by a signal, the exit status is the signal number plus 128.
83
84     entr normally returns one of the following values:
85
86           0       Normal termination after receiving SIGINT
87           1       No regular files were provided as input or an error oc‐
88                   curred
89           2       A file was added to a directory and the directory watch op‐
90                   tion was specified
91

EXAMPLES

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