LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   triggering bash script if directory modified (https://www.linuxquestions.org/questions/linux-software-2/triggering-bash-script-if-directory-modified-246286/)

cbb 10-23-2004 07:28 AM

triggering bash script if directory modified
 
I have a linux home box and a Solaris remote backup server
I am trying to write a bash script , so that if I locally save any file in a given directory on my home box , then the script will automatically detect that the directory has been modified and will run the script and backup the content of the directory to the remote server . is that possible ??
thanks

jschiwal 10-23-2004 07:52 AM

You could have a script run periodically by cron. I think that the best way to do it is to use the find command.
You could use the '-newer file' option to find files newer than a certain file. The file you use is simply one you create with the touch command, to create a file that is used as a time-stamp. The file command has an -exec option that can be used to call a command and hand it the list of new files. There is also an option to use a null byte instead of a return character in the list.
After the files are backed up, simply touch the time-stamp file again before finishing.


All times are GMT -5. The time now is 03:19 AM.