Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to monitor file system changes in linux

Tags:

I'm looking at building a file system sync utility that monitors file system activity, but it appears that some of the file system monitoring features in the linux kernel are obsolete or not fully featured.

What my research as found

dnotify came first with notification has the features of notifying for delete,modify,access,attribs,create,move can determine file descriptor, however is now out dated by inotify and fanotify

inotify came out second with notification has the features of notifying access, modify, attrib, close, move, delete, create, etc however it does not give you a file descriptor or process and will be outdated by fanotify

fanotify is the latest which informs of access, modify, close, but does not inform of delete or attribs, but does provide file descriptor

I need a way of determining the process (e.g. from fd) and things like delete, modify, attribs, etc in order to sync everything, any suggestions? Unfortunately dnotify seems the best but most out-dated

like image 880
ReDucTor Avatar asked Dec 05 '11 06:12

ReDucTor


People also ask

How do I monitor a directory 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. When we add a watch to a file, we can monitor it. For example, we'll know when a process opens, modifies, reads closes, moves, or deletes the file.

What is watchman Linux?

Watchman is an open source and cross-platform file watching service that watches files and records or performs actions when they change. It is developed by Facebook and runs on Linux, OS X, FreeBSD, and Solaris.

What does Inotifywait do in Linux?

inotifywait efficiently waits for changes to files using Linux's inotify(7) interface. It is suitable for waiting for changes to files from shell scripts. It can either exit once an event occurs, or continually execute and output events as they occur.

What is System Monitor Linux?

System Monitor is a tool to manage running processes and monitor system resources.


1 Answers

You should use a library instead of inotify and friends - something like FAM or Gamin (it's the same API for both). This will make your program portable to other Unixes.

like image 189
cnicutar Avatar answered Nov 06 '22 03:11

cnicutar