SCP command for copying .txt files from one remote server to another remote server for last 10 days
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
SCP command for copying .txt files from one remote server to another remote server for last 10 days
I have two remote hosts.
host1-> 10.2.3.2
host2-> 10.3.0.2
I have 500 txt file in one remote server. I want to copy it to another remote server using SCP command for last 10 days. I have userID & access to both server.How can I do this?
I have two remote hosts.
host1-> 10.2.3.2
host2-> 10.3.0.2
I have 500 txt file in one remote server. I want to copy it to another remote server using SCP command for last 10 days. I have userID & access to both server.How can I do this?
Not really enough details, but between the find command and the scp command, it should be pretty easy. First thing I'd do is use ssh-copy-id to make sure whatever user ID you have can log in without a password, using a key swap. After that, you can run a command via command-line with SSH to find files created in the last ten days, and copy them via SCP.
Pretty simple to script, just need a while loop to process the ssh file list.
You compose one or several scp commands that will do what you want. That's really basic stuff. If it doesn't work, show us what you got.
I don't get the "last 10 days" bit though.
I have tried with below command.
scp 'find /data1/client/apache-tomcat/icms_client/null/ -type f -name "*.txt" -mtime -10 -printf '%f\n'' user@10.2.3.2:/data1/client/apache-tomcat/icms_client/null
I have tried with below command.
scp 'find /data1/client/apache-tomcat/icms_client/null/ -type f -name "*.txt" -mtime -10 -printf '%f\n'' user@10.2.3.2:/data1/client/apache-tomcat/icms_client/null
but it's not working.
That command doesn't look right...have you read the man page on the find command?? And what do you mean by "not working"??? What does that command do and return?? http://man7.org/linux/man-pages/man1/find.1.html
Not sure what you're doing with the printf or the \n in your command, since the find command will return the file name(s) by itself, and the options should come first.
Code:
scp `find -type f -iname *.txt -mtime -10 /data1/client/apache-tomcat/icms_client/null/` user@10.2.3.2:/data1/client/apache-tomcat/icms_client/null
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.