Sponsored Content
Top Forums Shell Programming and Scripting how to delete files on two remote servers simultaneously? Post 302577536 by tiger2000 on Tuesday 29th of November 2011 09:47:24 AM
Old 11-29-2011
how to delete files on two remote servers simultaneously?

dear all,

i'm preparing a script which can do these actions :

1. stop remove server's certain service
2. clean the files on remote servers simultaneously (because lots of files need to be deleted)
3. after files/logs are removed, restart the service again

i'm stuck on how to clean remote servers's files at the same time to save time.

this is the code i have right now :
(by the way, i have setup the auto ssh-login mechanism, thus, passwd is not necessary when running ssh command)

Code:
MAILERS=(192.168.1.1 192.168.1.2)

# stop service
for ((index=0; index<${#MAILERS[@]}; index++)); do
   ssh ${MAILERS[$index]} "service my_service stop"
done

# delete those files matching $1 variable
for ((index=0; index<${#MAILERS[@]}; index++)); do
   ssh ${MAILERS[$index]} "find /path -name '*$1*' -exec rm {} \;"
done

# start the service again
for ((index=0; index<${#MAILERS[@]}; index++)); do
   ssh ${MAILERS[$index]} "service my_service start"
done

to be more specific, how to run the "find-exec-rm" command on both servers simultaneously?

just put the & in end of it is not what i want...

any advice on this? Thanks.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to parse 2 files simultaneously

Say I have 2 files of 2 rows of 3 columns each file1: cat catdata1 catdata2 dog dogdata1 dogdata2 file2: cat catdata3 catdata4 dog dogdata3 dogdata4 and I need to combine both files so that is appears like: cat catdata1 catdata2 catdata3 catdata4 dog dogdata1 dogdata2 dogdata3... (8 Replies)
Discussion started by: Awanka
8 Replies

2. Shell Programming and Scripting

Find files not accessed on a remote server and delete - Help!

Hi Guys, I am currently working on a script to find all the files that have not been accessed for the past 2 years. This, i guess has been discussed n number of times in this forum. Now, my requirement is to find all the files in the remote windows server. I have it mounted in unix. I was... (1 Reply)
Discussion started by: bond_bhai
1 Replies

3. UNIX for Advanced & Expert Users

delete files on a remote server

Hi Guys, I am currently working on a script to find all the files that have not been accessed for the past 2 years. This, i guess has been discussed n number of times in this forum. Now, my requirement is to find all the files in the remote windows server. I have it mounted in unix. I... (1 Reply)
Discussion started by: bond_bhai
1 Replies

4. AIX

Get the list, filter and delete the files on remote server

Hi, I need to login to a remote server. Go to a particular path. Get the lists of files on that path.There may be n number of files. I need to delete only those files from above created list which are 7 days older. I have achieved above using ftp protocol, but now the constraint has... (0 Replies)
Discussion started by: mail_amitnagpal
0 Replies

5. Shell Programming and Scripting

Looping through 2 files simultaneously

Hi all, I'm having a problem with a script which should ultimately provide a filename by reading a value from file1 and file2 then join together. I'm planning to use a loop/ loops to get the values out of both files and create a single string unfortunately the code currently treats the second... (7 Replies)
Discussion started by: chris01010
7 Replies

6. Shell Programming and Scripting

Remove Duplicate Files On Remote Servers

Hello, I wrote a basic script that works however I am was wondering if it could be sped up. I am comparing files over ssh to remove the file from the source server directory if a match occurs. Please Advise me on my mistakes. #!/bin/bash for file in `ls /export/home/podcast2/"$1" ` ; do ... (5 Replies)
Discussion started by: jaysunn
5 Replies

7. Shell Programming and Scripting

script to delete multiple files in remote machine

Requirement Several files in remote machines ought to be deleted via sh. Name of the files to be deleted are know Approach 1) script was written with ftp (requires credential) and delete command. File names were passed as array(iterated via for loop-with ftp+delete commands enclosed within... (1 Reply)
Discussion started by: vkalya
1 Replies

8. UNIX for Dummies Questions & Answers

Help with Copying files between two remote servers

Hi All, Please help me for a shell. I am a New to unix I am trying to DB dump file from one server and copying it to another server. From My Local ServerA connecting to remote ServerB using ssh and taking dump of a instance. That Dump file i need to copy to ServerC. I am able to connect... (6 Replies)
Discussion started by: maddyd2k
6 Replies

9. How to Post in the The UNIX and Linux Forums

Simultaneously try to execute commands after connecting to remote account to one account

I have made password less connection to my remote account. and i tried to execute commands at a time. but i am unable to execute the commands. ssh $ACCOUNT_DETAILS@$HOST_DETAILS cd ~/JEE/*/logs/ (1 Reply)
Discussion started by: kishored005
1 Replies

10. Shell Programming and Scripting

Shell Script to delete files from 5 different servers

Hello, I'm new to shell scripting and need a quick note on how to write a shell script to perform deletion of files from 5 different hostnames in various locations. Found out to delete files from one path by using below command and made it to work on cron job but need to do it in a shell... (2 Replies)
Discussion started by: Teja G
2 Replies
TCPSPY.RULES(5) 						   tcpspy.rules 						   TCPSPY.RULES(5)

NAME
tcpspy.rules - configuration file for tcpspy DESCRIPTION
This file, by default /etc/tcpspy.rules, is read by the /etc/init.d/tcpspy script at init time in order to configure tcpspy (see tcpspy(8)) logger filtering rules. It might look like: # /etc/tcpspt.rules example user "joedoe" and rport 22 and raddr 192.168.1.10 user 1003 lport 22 or lport 21 (lport 23 and user "joedoe") or raddr 192.168.1.20 This rules file specifies that tcpspy logs tcp connections according to 4 rules (line 1 to line 4 - one per each line) using the boolean logic (see below) to evaluate each rule. This particular example logs conections: line 1 - for user "joedoe" connecting to 192.168.1.10:22 (remote) line 2 - for user whose UID is 1003 line 3 - to localhost:22 or localhost:21 line 4 - for user "joedoe" to localhost:23 or to 192.168.1.20 (remote) Everything from an "#" signal and the end of the line will not be evaluated. Rule Syntax - just extracted from tcpspy(8) A rule may be specified with the following comparison operators: user uid True if the local user initiating or accepting the connection has the effective user id uid. user "username" Same as above, but using a username instead of a user id. lport port True if the local end of the connection has port number port. lport [low] - [high] True if the local end of the connection has a port number greater than or equal to low and less than or equal to high. If the form low- is used, high is assumed to be 65535. If the form -high is used, low is assumed to be 0. It is an error to omit both low and high. lport "service" Same as above, but using a service name from /etc/services instead of a port number. rport Same as lport but compares the port number of the remote end of the connection. laddr n.n.n.n[/m.m.m.m] Interpreted as a "net/mask" expression; true if "net" is equal to the bitwise AND of the local address of the connection and "mask". If no mask is specified, a default mask with all bits set (255.255.255.255) is used. raddr Same as laddr but compares the remote address. exe "pattern" True if the full filename (including directory) of the executable that created/accepted the connection matches pattern, a glob(7)-style wildcard pattern. The pattern "" (an empty string) matches connections created/accepted by processes whose executable filename is unknown. If the -p option is not specified, a warning message will be printed, and the result of this comparison will always be true. Expressions (including the comparisons listed above) may be joined together with the following logical operations: expr1 or expr2 True if either of expr1 or expr2 are true (logical OR). expr1 and expr2 True if both expr1 and expr2 are true (logical AND). not expr True if expr is false (logical NOT). Rules are evaluated from left to right. Whitespace (space, tab and newline) characters are ignored between "words". Rules consisting of only whitespace match no connections, but do not cause an error. Parentheses, '(' and ')' may be placed around expressions to affect the order of evaluation. Examples These are some sample rules which further demonstrate how they are constructed: user "joe" and rport "ssh" Log connections made by user "joe" for the service "ssh". not raddr 10.0.0.0/255.0.0.0 and rport 25 and (user "bob" or user "joe") Log connections made by users "bob" and "joe" to remote port 25 on machines not on a fictional "intranet". AUTHOR
Tim J. Robbins (tcpspy), Pablo Lorenzzoni (this manpage) SEE ALSO
glob(7), proc(5), services(5), signal(7), syslog(3), tcpspy(8) Spectra April 2001 TCPSPY.RULES(5)
All times are GMT -4. The time now is 04:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy