Friday, November 26, 2010

Directory watcher

Directory watcher will update update.txt file with what are the file or directories removed or added from previous run of script.

This is totally shell script.
First copy with dir_watcher name and give execution permissions and run as "./dir_watcher dir_path"

For the first time runs. It takes snapshot of ur directory structure which was provided in cmd.
When second time runs it will take snapshot of directory and if any new files or dir are added then those updates will be written in to update.txt in parent directory.
If dir path not mentioned it will take present dir.

Note:- It won't give information of updated files.
Put this script in crontab so it will run periodically and updates log file with changes.
ex:- 0 12 * * * sh /bin/dir_watcher /home/balu/project/
So, every day at 12 noon it will run and updates the update.txt file in "/home/balu/project/"

No comments: