2013/7/11 Joseph <syscon...@gmail.com>: > I just want to monitor one file in a directory. > I usually copy the file over the network to another computer (same file > name) I'll overwrite the file. > > Once I copy the file, the system should notify a use that new file exist (a > message pop-up). If the use closes the message and will not open the file, > after few ours I want to remind the user that the file has not been open > yet. > > Will it be very complicated to write a bash script like this?
I once wrote a small Python script to help me with automating Git-based deployments, but it's simple enough to be suitable for a variety of use cases: https://github.com/xen0n/touchmon It allows you to specify a hook for each file observed, just make sure the watched file exists before starting the watcher (a known limitation). Inside the hook script (any language is OK) you can pop-up a dialog and store a timestamp somewhere, if the user has the file opened for him/her. Then for the periodic notofication, maybe a cronjob would suffice? Simply check the stored timestamp with the current time. If polling is not what you want, you can extend the inotify part to also monitor events like IN_OPEN or IN_ACCESS and manipulate your timer accordingly. But be aware of false positives like some background daemon accessing the file, as ALL opens and reads are watched. Hope this helps~