Reputation: 1403
scp user@server:/home/loghost??/logfiles.log .
i'm using above scp command in my unix script to download all the logs from loghost folder.
there are mutliple loghost are avaible in my server(i.e. loghost01,loghost02,loghost03)
The log name is same in all the loghost folder. So while scping, the logs are getting override. Is there a way to change the logname while copying?
Upvotes: 0
Views: 305
Reputation: 3773
Put logs from different servers into different directories:
for server in loghost{01,02,03}
do
mkdir -p $server
scp user@$server:/home/$server/logfiles.log ./$server/
done
Put logs from different servers into the same directory with different names:
for server in loghost{01,02,03}
do
scp user@$server:/home/$server/logfiles.log ./$server.log
done
Upvotes: 0
Reputation: 4270
for server in loghost01 loghost02 loghost03; do
mkdir -p $server;
scp user@$server:/home/$server/logfiles.log $server/;
done
I think something like that might help. It takes a list of your servers, scps files over to a folder named loghost##/logfiles.log.
If you have a list of servers in a text file, replace the top line with:
for server in `cat file_containing_servers`; do
Upvotes: 1