CentOSThis forum is for the discussion of CentOS Linux. Note: This forum does not have any official participation.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
inotify was designed for this purpose. You'd have to write a shell script with a while loop running forever. And start this script at system boot. It is quite efficient as a process in wait state does not consume any processor cycles. Once you get the signal you can perform an rsync action. Because you are watching a directory but you don't know which file has changed. That is for rsync to find out and handle.
The inotify man page provides useful examples.
OTOH if you call rsync from cron you have some time between the creation of the file and sync action. Moreover, rsync use is not free. It takes processor and disk cycles. If you run it very frequently (every 5 minutes or so) and your directory contains many files it is inefficient. But calling rsync from cron is quite simple.
So it boils down to simplicity vs. efficiency. (as usual)
ok i have edited incrontab, my incrontab looks like this -
[root@script ~]# incrontab -l
/source/ IN_CREATE,IN_DELETE,IN_CLOSE_WRITE /usr/bin/rsync /dest/
[root@script ~]# ls /source/
qwerty qwerty.csv
[root@script ~]# ls /dest/
[root@script ~]#
can anyone suggest why it isnt working as it should rsync stuff in source to dest?
You're not specifying a source for your rsync command.
If you use IN_CREATE then the event will "fire" when the file is created, before data has finished writing to it so may have unpredictable results. You also never originally mentioned anything about deletion.
if those files were there before you set up the incrontab entries then they wouldnt have triggered the relevant event so your jobs wouldnt get activated.
If that doesn't give you enough of a clue as to how to proceed then let me know and I'll look at it in more detail in the morning when I'm actually at a machine.
Last edited by TenTenths; 08-24-2017 at 05:39 PM.
Reason: Had IN_WRITE_CLOSE instead of IN_CLOSE_WRITE, It's late and my eyes are tired :(
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.