3 ms·
How to signal an already running process whenever some file is renamed
I am working on a project to manage files. The idea is to transfer information about a file's location through file name itself. So, whenever a user renames a file, the process will scan the filename and move it to the desired location. But I don't know how to signal the process whenever any file is renamed.
- zimpenfish 16y agoIsn't this the kind of thing that FAM was invented for? http://oss.sgi.com/projects/fam/ http://oss.sgi.com/projects/fam/ http://en.wikipedia.org/wiki/File_alteration_monitor http://en.wikipedia.org/wiki/File_alteration_monitor (Or specific things like inotify on Linux: http://en.wikipedia.org/wiki/Inotify http://en.wikipedia.org/wiki/Inotify )
- zimpenfish 16y ago(as in your process monitors the directory itself and picks up the renames without having to be signalled by another process - although you could just give it a SIGHUP when another process using FAM/inotify notices the rename but why complexify things?)
- db42 16y agoBut then, process will have to continuously keep a check on the directory. So, the time interval will need to be figured out for the process to wake up and check the directory for the renames.
- db42 16y agoIt seems that inotify will be perfect for my requirement. Thanks a lot..