I want to run a script from my Jump server, have it SSH to a server, then run a command (like rm <file>
, top
or ls -lsa
) then take that output and put it in to a file on my Jump server then move on to the next IP in the list.
I would like to be able to provide the script a list of IP address and have it execute the script on all of them.
So far I have
ssh <IP> 'find ./<Path> -mtime +15 -exec rm <filename> {} \;' > <filename>
But all this does is ssh to the box, run the command and list the info. I need it to run the command, output the data to a file on my jump server and then move on to the next box.
Any suggestions?
for
loop which repeats the action for different hosts and the output redirection>"$log_file" 2>&1
– Hauke Laging Jun 06 '13 at 21:52