Keep Remote Directory Up-to-date

后端 未结 17 1739
一向
一向 2021-01-30 06:39

I absolutely love the Keep Remote Directory Up-to-date feature in Winscp. Unfortunately, I can\'t find anything as simple to use in OS X or Linux. I know the same thing can

17条回答
  •  悲哀的现实
    2021-01-30 07:31

    What you want to do for linux remote access is use 'sshfs' - the SSH File System.

    # sshfs username@host:path/to/directory local_dir
    

    Then treat it like an network mount, which it is...

    A bit more detail, like how to set it up so you can do this as a regular user, on my blog

    If you want the asynchronous behavior of winSCP, you'll want to use rsync combined with something that executes it periodically. The cron solution above works, but may be overkill for the winscp use case.

    The following command will execute rsync every 5 seconds to push content to the remote host. You can adjust the sleep time as needed to reduce server load.

    # while true; do rsync -avrz localdir user@host:path; sleep 5; done
    

    If you have a very large directory structure and need to reduce the overhead of the polling, you can use 'find':

    # touch -d 01/01/1970 last; while true; do if [ "`find localdir -newer last -print -quit`" ]; then touch last; rsync -avrz localdir user@host:path; else echo -ne .; fi; sleep 5; done
    

    And I said cron may be overkill? But at least this is all just done from the command line, and can be stopped via a ctrl-C.

    kb

提交回复
热议问题