Command Line Filesystem Watcher



This is a screen shot of the application running.

This project came about when I needed a tool to run unit tests whenever I changed production code in a local development environment. There are other uses cases for the application listed here .

Software Prerequisites

 A Java 8 (or better) Runtime Environment is required to run this application.


The demos have the following dependencies.

  • linux operating system (or at least BASH)
  • sox package to play audio files
  • festival - for text to speech
  • festival-us - for an actual voice. other languages are available besides English

Software Walkthrough

 The main logic of this application is in the DirectoryWatcher class.

It uses a java.util.Timer instance and java.util.TimerTask instances to schedule system commands for execution.

Once a change is detected the code calls the DirctoryWatcher#processModification() method to determine if the changed file's type is configured to actually process the file. The configuration parameters are set in a user specified the properties file (or command line arguments).

For lower level details of the built-in Java NIO APIs used in this project, see the 'Resources' section for links to sample code provided by Oracle .

Running the Application


The issue 'java -jar onebeartoe-filesystem-cli-watcher-cli-jar-with-dependencies.jar '

This invocation is missing parameters, and prints a usage message. A more convenient way to use the application is with a properties file and shell script to invoke the application. This other option is reviewed next.

Running the Application with a Script and Properties File

 See the properties file linked above and this bash script to optionally run the application with a configuration saved to disk for reuse.


 The main goal of this tool is watch the filesytem for changes. Using it involves configuring what file you want to watch and then verifying the command(s) execute (after any configured quiet period) in the terminal window, when a file is actually changed.

To exit the application, hit Ctrl-Z at the terminal.

Going Further

Here are some ideas to take this application further.

  • Allow for more than on file type configuration.
  • Specifiy the working directory (an not always use the current directory).
  • !!!!!!!!!!TODO: add a link to the demos.
    Provide examples of how to use sound clips to indicate successful/failed command execution.
  • Specify a debug level for the logging, to de-clutter the output messages.
  • Provide some GUI to configure the application.

Date Created

Sat Oct 10 13:39:16 MDT 2020

Last Updated

Mon Oct 26 22:18:16 MDT 2020

watcher filesystem tools

back    |    top