I have linux client and linux server. Both are Ubuntu 16.04.
On the client I generated .txt files almost every second, and I want to transfer them to the server, so my question is: what is the best solution for this purpose?
I did this script:
#!/bin/bash
path="/home/path"
while true
do
for entry in "$path"/*.txt
do
if [ -f "$entry" ]
then
scp "$entry" [email protected]:/home/4lkov/Desktop/scp && rm -f "$entry"
else
echo "No files";
fi
done
sleep 1
done
So, I'm using SCP is it reliable or is there best ways (rsync or similar)?
Also I'm using sleep 1.. probably there is some watchdog? (i.e inotifywait -m /path -e create -e moved_to |
)
inotifywait
on the directory will do the job.scp
is fine,rsync
is more appropriate when you have many files (which you won't have unless you make theinotifywait
code more complex by accumulating filenames for a while between transfers).rsync
does have an option to remove the source file on completion of the transfer, though, if that is needed.sshfs
and just create the files on the remote machine to start with?