Watch command in a shell script
I want to make a script that runs in cron that watches a folder for changes, and IF a change occurs, I'd like to make it email me. Is it possible to get output from the watch command when it's running in the background?
|
As long as the script itself receives all the output but it would be relatively complex coding (watch runs until killed so you would have to run it in a sub-process and kill it at intervals, all within a timed loop) and inefficient.
Have you considered inotify instead of watch? |
I've never heard of inotify. I did an apt-cache search in debian lenny, and never found 'inotify', but I did find inoticoming. Sounds to be exactly waht I need - triggers actions when files hit an incoming directory. Thanks!
|
You might also want to consider incrond. Here are some links to give you an idea of it.
http://linux.die.net/man/8/incrond http://linux.die.net/man/5/incron.conf http://linux.die.net/man/5/incrontab |
Quote:
Glad the disinformation lead you to a solution, though! :) |
Thanks for the suggestions. I like the idea of incrond the best but I find it slightly confusing. I have the daemon running, but how do I define a permanent file it will use? or how often the directory is checked? How would I make it watch for an incoming zip file?
For incoming zip file, I'm assuming I have to edit my incrond file (which I still don't know how to permanently define) to something along the lines of this: /home/me/zips/ IN_CREATE *.zip I think that's still wrong, however. |
All times are GMT -5. The time now is 11:20 PM. |