You can use the following program to update folder2
whenever you save new files or update folder1
:
while inotifywait -r -e modify -e move -e create -e delete; do
cp -r /stuff/folder1/. /stuff/folder2/
done
For the schedule thing I would add cp -r /stuff/folder1/. /stuff/folder2/
into a cron job. Instead of cp
you can also use rsync. Please also have a look on the manpage of inotifywait.
Note: The above script will start the copy after the first file was altered inside the directory folder1
. If you modify many files in folder1 in the same time, you might want to put a sleep
command inside the while loop. But in this case it is better to add the copy command at the end of the program which alters the files of folder1
.