Saturday, April 20, 2024
 Popular · Latest · Hot · Upcoming
25
rated 0 times [  25] [ 0]  / answers: 1 / hits: 37188  / 1 Year ago, wed, november 2, 2022, 9:58:38

I can sync folders with rsync -avz /directory /target, now I wish to do it if I changed a file in /directory so rsync should be called automatically.



I am using Virtual Box and the shared folder of Virtual Box is really slow, especially if you have a webpage which is using the shared folder as document root. With rsync i would be able to work with my local files on shared folder and sync it automatically with document root.



I hope someone has an idea how to do so,crontab would be not good, because it is executed each x minutes, so if i don't do anything, it will still call rsync but not if I modified my file.



Best regards


More From » virtualbox

 Answers
5

crontab would be not good, cause it is executed each x seconds/minutes, so if i dont do anything, it will still call rsync but not if i modified my file




rsync will only sync the files that have been changed. If nothing has changed, it will exit. That's really a minimal overhead.



If you're unhappy with that you could use inotifywait:



while inotifywait -r /directory/*; do
rsync -avz /directory /target
done


That will be more instant but it will do things every time you save.


[#29693] Friday, November 4, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lintical

Total Points: 344
Total Questions: 122
Total Answers: 106

Location: Sint Maarten
Member since Mon, Oct 12, 2020
4 Years ago
lintical questions
Thu, Jan 12, 23, 03:07, 1 Year ago
Mon, Jun 28, 21, 07:01, 3 Years ago
Sat, Aug 7, 21, 04:29, 3 Years ago
Mon, Dec 5, 22, 00:03, 1 Year ago
;