Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Program to re-run, eg, `make` when files are modified?

Tags:

makefile

Is there a program that will automatically re-run, eg, make, when files are modified?

For example, when I'm writing sphinx documentation, it would be nice if make html was run automatically each time I edit any relevant files.

like image 496
David Wolever Avatar asked Dec 07 '10 19:12

David Wolever


People also ask

How does make know when a file has changed?

Make works by inspecting information about files, not their contents. Make works out dependencies between targets and their dependencies, and then looks to see whether the files exist. If they do, it asks the operating system for the time and date the file was last modified.

How do you run the command every time a file is modified in Linux?

entr. entr is a simple and excellent command-line utility for running arbitrary commands when any modifications occur in a given directory. “entr” stands for Event Notify Test Runner.

What flag makes just keep watching for changes in files to re execute?

To watch log files that get rotated on a daily base you can use the -F flag to tail command. The tail -F will keep track if new log file being created and will start following the new file instead of the old file.

How will you monitor file change in Linux?

In Linux, we can use the inotify interface to monitor a directory or a file. We do this by adding a watch to the directory or file.


1 Answers

Well, since make will not do anything if nothing has changed, how about

while true; do sleep 60; make html; done

or the equivalent in your shell of choice? I don't think the usual file system layers are event-driven in such a way that they will you notify you of file changes without doing some similar themselves, but it's possibly DBUS can do that sort of stuff.

like image 186
Ulrich Schwarz Avatar answered Sep 28 '22 05:09

Ulrich Schwarz