LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   scp/ssh tail(multiple file) remote copy (https://www.linuxquestions.org/questions/linux-general-1/scp-ssh-tail-multiple-file-remote-copy-355765/)

tpreitano 08-22-2005 07:24 AM

scp/ssh tail(multiple file) remote copy
 
I currently have a crontab running a script like so..............

/usr/bin/scp username@x.x.x.x:/data/noaa/bigross/'*.Z' /data/products/hrpt/bigross/
/usr/bin/scp username@x.x.x.x:/data/noaa/ross/'*.Z' /data/products/hrpt/ross/
/usr/bin/scp username@x.x.x.x:/data/noaa/mcmu/'*.Z' /data/products/hrpt/mcmu/
/usr/bin/scp username@x.x.x.x:/data/noaa/spole/'*.Z' /data/products/hrpt/southpole/

I want to incorporate something like ls -tr | tail -3, so I can get the last three files to date, instead of all. I don't mind changing the script to use ssh login first. Please advise. Thanks Ahead.

TPR

zedmelon 08-22-2005 02:17 PM

a loop?
 
Not sure I grasp what you want to do, but a loop should work. I can't think of a way to lump all the filenames into one command, so this would require either RSA key login, or a password entry each time.

for FILE in `ls -tr | tail -3`
do
scp user@host /path/$FILE .
done

Or you could look into using rsync, which copies only updated files and can use ssh as the connect protocol.


All times are GMT -5. The time now is 10:30 AM.