|
#1
|
|||
|
|||
|
Hello everybody,
Do you know if it's possible to detect when some new files are put into a directory? I mean, is it possible to monitor a directory in order to do something when a new file is added, or modified, or whatever in that directory? What do I want to do? I want to monitor a directory where users can put files via FTP, and whenever a new file arrives, I want to start processing it. I am currently using a cronjob that executes every 5 minutes or so, but that's a lousy solution because our users are transferring the files not that often. However, I cannot use a longer period of time because the users expect their files processed soon enough. I don't want to waste resources running the cronjob, and I want to give the users a good experience. Any suggestions are welcomed... Regards, HLR |
|
#2
|
|||
|
|||
|
On Linux you can use dnotify: F_NOTIFY with fcntl(2). It's a bit icky, but it
does what you need. With newer (2.6.13) kernels you can also use inotify(7). An alternative is to use a file monitoring library or daemon like Gamin or FAM, which is more portable and falls back on polling if no suitable notification method is available. |
|
#3
|
|||
|
|||
|
Quote:
Thank you. I checked but unfortunately inotify is not available on the system, and unfortunately I cannot make any modifications to the system. dnotify actually works, and it's quite fine for what I want to do. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|