Watcherd Shell Listener for Directory Changes in Linux
Last Updated :
29 Jan, 2021
Watcherd is a tool for Linux that helps to monitor directory changes and print whatever changes are done like adding and deleting for a particular directory and execute commands and shell scripts according to a particular event.
Installing Watcherd on Linux
Step 1: Downloading watcherd.
Since watcherd is a Github repository you can use wget command to download its zip and extract it. To do so execute the command:
wget https://github.com/devilbox/watcherd/archive/master.zip
Step 2: Unzipping and extracting.
After downloading unzip the file using the command:
unzip master.zip
In case you do not have to unzip installed then you can install it by using:
sudo apt-get install unzip
Step 3: Copy to the bin location.
Once unzipping is finished now you need to copy the files to the bin directory, to do so use the command:
sudo cp watcherd-master/watcherd /usr/bin/
Step 4: Check the tool is installed properly or not.
You can check the user manual by using the help command:
watcherd --help
Output:
Or you can check with --version
watcherd --version
Output:

Watcherd Working:
Step 1: Create a directory.
Make a directory named test in your current working directory
mkdir sample
Step 2: Now start watcherd.
Now deploy watcherd using the following parameters:
watcherd -v -p ~/sample -a "echo added %n" -d "echo deleted %n" -t "ls -l ~/sample" &
Output:

where
- -v stands for verbose which will verbosify the output of the command
- -p stands for the path to directory, and we have used test for the subject
- -a stands for executing the command if any directory path is created , we have used echo for printing but you can also add any other way of scripting and make the best use out of it.
- -d stands for executing the command if any directory path is deleted and vice versa.
- %n will be substituted with directory name or you can use %p to get a full path to the created or deleted directory
- -t "ls -l ~/test" execute command after triggering
- & run in background
Step 3: After executing the command check if it's running by using the command:
ps ax | grep watcherd
Output:
Now let's do some adding and deleting directory in our test folder and see what happens, directory can be named anything, for instance we are using anon.
mkdir sample/anon
Output:

rmdir sample/anon
Output:
After executing the command you will be able to see an output generated by watcherd.
Similar Reads
How to Count Files in Directory Recursively in Linux When exploring directories on your server, you may have come across folders with a large number of files in them. You might wish to know how many files exist in a certain directory or across many directories at times. To put it another way, you wish to count the number of files saved in a directory
5 min read
Introduction to Linux Shell and Shell Scripting If we are using any major operating system, we are indirectly interacting with the shell. While running Ubuntu, Linux Mint, or any other Linux distribution, we are interacting with the shell by using the terminal. In this article we will discuss Linux shells and shell scripting so before understandi
8 min read
Linux Shell Script to Sync Directories Interactively Scripts that sync directories are scripts used to synchronize the contents of two directories. This means that the script will ensure that the two directories have duplicate files and directories and that the contents of the files are the same. There are various ways to sync directories, and the spe
7 min read
How do Change Streams Work In MongoDB? Change Streams in MongoDB allow applications to access real-time data changes without the complexity and overhead of polling the database. They provide a powerful and efficient way to listen to changes in collections, databases, or entire clusters. These are the following sub topics that we are goin
3 min read
How to Listen for Changes to a MongoDB Collection? Tracking changes in MongoDB is essential for applications requiring real-time updates or synchronization with the database. Traditionally, this was achieved through polling, which could be inefficient. MongoDB offers more effective methods to track changes including Change Streams, the watch() metho
6 min read