fswatch is a cross-platform, file change monitor that gets notification alerts when the contents of the specified files or directories are altered or modified.
It executes four types of monitors on different operating systems such as:
- A monitor build on the File System Events API of Apple OS X.
- A monitor based on kqueue, a notification interface present in FreeBSD 4.1 also supported on many *BSD systems, OS X inclusive.
- A monitor based on File Events Notification API of the Solaris kernel plus its spin-offs.
- A monitor based on inotify, a kernel subsystem that shows file system modifications to apps.
- A monitor based on ReadDirectoryChangesW, a Windows API that records alters to a directory.
- A monitor that regularly check that status of file system, keeps file modification times in memory, and manually determine file system changes (which works anywhere, where stat can be used).
Features of fswatch
- Supports several OS-specific APIs
- Allows recursive directory monitoring
- Performs path filtering using including and excluding regular expressions
- Supports customizable record format
- Additionally, it supports periodic idle events
How To Install fswatch in Linux Systems
Unfortunately, fswatch package is not available to install from the default system repositories in any Linux distributions. The only way to install the latest version of fswatch is to build from source tarball as show in the following installation instructions.
First grab the latest fswatch tarball using following wget command and install it as shown:
Important: Make sure you’ve GNU GCC (C and C++ Compiler) and Development Tools (build-essential on Debian/Ubuntu) installed on the system, before you compile fswatch from source. If not, install it using following command on your respective Linux distributions..
On Debian/Ubuntu distributions, you might get following error while executing fswatch command..
To fix it, you need to execute the command below, this will help refresh the links and cache to the dynamic libraries before you can start using fswatch.
How do I use fswatch on Linux?
The general syntax for running fswatch is:
On Linux, it is recommended that you use the default inotify monitor, you can list available monitors by employing the
-M
or - list-monitors
option:
The command below enables you to watch the changes in the current directory (
/home/tecmint
), with events being delivered to standard output every 4 seconds.
The
-l
or –-latency
option allows you to set the latency in seconds, the default being 1 second.
No comments:
Post a Comment