Skip to content
Latchkey

entr: Re-Run a Command When Files Change

entr reads a list of file paths on stdin and runs a command each time any of those files changes, making it a tiny, portable file-watch loop.

entr is the classic Unix watcher: you feed it a file list (usually from find or fd) and a command, and it reruns on save. Like watchexec, it loops, so it is local-only.

What it does

entr takes a newline-separated list of file paths on stdin, then blocks and watches exactly those files. When one changes it runs the command you passed as arguments. -r reloads a persistent process (restart); -c clears the screen first; -d exits if a new file appears in a watched directory so a wrapping loop can re-scan.

Common usage

bash
find . -name '*.py' | entr pytest          # rerun tests on change
fd -e go | entr -r go run .                 # restart the server
ls *.tex | entr -c make                     # clear screen, rebuild
# re-scan when files are added/removed:
while true; do fd -e rs | entr -d cargo test; done

Options

FlagWhat it does
-rReload: restart a persistent child process on change
-cClear the screen before each run
-dExit if a directory gains a new file (for a rescan loop)
-sRun the argument as a shell command (allows pipes)
-pPostpone the first run until the first change
/_Placeholder replaced with the changed file name

In CI

entr is a local development loop, not a CI step: it blocks waiting for changes and never returns, which would stall the pipeline. Use it on your machine for tight test feedback. In an automated environment, run the underlying command (pytest, make) once instead.

Common errors in CI

"entr: No regular files to watch" means stdin was empty: the find/fd upstream matched nothing, often because of a wrong path or ignore rules. "entr: command not found" (install via apt-get install -y entr or brew install entr). A job that hangs forever after an entr invocation is entr doing its job; it should not be in CI.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →