1851051 Members
2949 Online
104056 Solutions
New Discussion

script wanted

 
SOLVED
Go to solution
peterchu
Super Advisor

script wanted

I want to have a script to do the following task.

1. rcp the files that are within 7 days from local host ( eg. /tmp ) to the same path at other hosts ( total ten hosts ) .

2. check the above rcp whether success , if any files that are not succssfully do the rcp , redo the rcp until it is success.

could help to make the draft for it , very thx.
2 REPLIES 2
KapilRaj
Honored Contributor
Solution

Re: script wanted

Have not tested hence check it before making it online

It is better to investigate the left files than trying to copty again !!

#
if [ $# -lt 2 ]
then
echo "Syntax $0: directory node1 node2 ...."
exit 8
fi

DIR=$1
shift

if [ ! -d $DIR ]
then
echo $DIR not a directory
exit 8
fi

function check_error {
if [ $? -ne 0 ]
then
echo Could not copy $FILE onto $NODE
fi
}

for FILE in `find $DIR -mtime 7 -print |sed `
do
for NODE in $*
do
rcp $FILE $NODE:$FILE
check_error
done
done

regds,

Kap
Nothing is impossible
rmueller58
Valued Contributor

Re: script wanted

are you setting a time/date stamp in the file name somehow?

such as cp filename filename`date+%m%d%y` ?