Saturday 14 October 2017

ssh - Linux: Continuously synchronize files, one way


Scenario: An IDE is set up on a Linux desktop box, editing PHP files locally. Every time I save a file, I want this change to appear on the linux server where Apache is running. The server has ssh (and samba and nfs for that matter).


As a reference, when I edited files on Windows, I finally came over WinSCP as the exact tool I needed - WinSCP have just this feature present, with initial synch and then continuous update, using the filesystem watch service: "Keep Remote Directory up to Date".


On Linux, one could argue that sshfs could be employed to sidestep the need for synchronization entirely. On windows, a samba-share would do the same. However, I want the IDE to work with local files (on a SSD disk!), not having to go over the network to do PHP indexing and whatnots, which takes ages.


But sshfs might be a part of the solution nevertheless - so that the continuous synchronization just needed to be done between two local directories.


Any ideas or pointers?



Answer



You can also use inotifywait from the inotify-tools package.


inotifywait -r -m -e close_write --format '%w%f' /tmp | while read MODFILE
do
echo need to rsync $MODFILE ...
done

No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...