-   Linux - General (
-   -   scp/ssh tail(multiple file) remote copy (

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.


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`
scp user@host /path/$FILE .

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 07:15 AM.