Our great sponsors
-
entr
A utility for running arbitrary commands when files change. Uses kqueue(2) or inotify(7) to avoid polling. entr responds to file system events by executing command line arguments or by writing to a FIFO. entr was written to provide to make rapid feedback and automated testing natural and completely ordinary. (by clibs)
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
fswatch
A cross-platform file change monitor with multiple backends: Apple OS X File System Events, *BSD kqueue, Solaris/Illumos File Events Notification, Linux inotify, Microsoft Windows and a stat()-based backend.
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
-
WatchMod
Watch for modifications to trigger actions. Useful for compiling Go templates, Sass, Typescript, and more.
Not sure what generated interest in this.
This was a project I did for my personal use case. But I haven't been using it since years. I'd recommend [entr](https://github.com/clibs/entr) for the use case watchman was to serve.
Not to be confused with Facebook’s file watch daemon, which does the same sort of thing but is more complicated. There’s a bunch of tools that integrate Facebook’s watchman for more efficient change tracking.
https://facebook.github.io/watchman/
I've used `incron`[0] for that purpose, with success
[0]https://github.com/ar-/incron
The required kernel hooks exist in pretty much any common OS these days, it is a user-space tool that is sometimes missing.
It may not be installed by default, but inotifywait is available in common Linux distributions, usually in a package called something like ionotify-tools, and has been for over a decade-ana-half IIRC. It'll work under WSL on Windows too, though only for ext4 devices not bits of the Windows filesystem made available to Linux.
I can't speak to what other OSs include by default, but as every major OS has a different API for defining how to register a lister and how it gets messages no built-in tool is going to be cross platform. There are third party tools which present more cross-platform consistency, most notably https://github.com/emcrisostomo/fswatch#readme (also available in common Linux distros, just an apt install away in Debian for instance).
Also not to be confused with watchdog and it's command watchmedo, which is what I thought this was when I first read the headline. I don't know what the differences are, but I use this to restart my local celery workers when I make changes. It's scripted out so I don't ever use the command directly.
https://pypi.org/project/watchdog/
https://github.com/gorakhargosh/watchdog
Here was our take on the problem written in Go.
https://github.com/Cyphrme/watch
{
Those considering doing something like this (such as the author) might consider using my library:
https://github.com/e-dant/watcher
It hooks into system APIs where viable. (Otherwise, it uses std::filesystem.)
It’s meant to be as or more:
Easy to use
The page linked above says:
> WARNING: This is a (possibly outdated and/or unmaintained) fork of https://github.com/eradman/entr .
I wrote something very similar.
https://github.com/m00dy/fwe
Related posts
- MakeMake: Generate make files from C source code
- Are there any CLIs or good ways on macOS to real-time / continuously sync two folders on the same drive?
- Build a Rails script watcher/runner using fswatch
- Is there a way to trigger an action when a file is transfered via another computer?
- Script only runs when it sees new file that fits criteria help needed