- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- File consistency
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2009 07:13 PM
07-05-2009 07:13 PM
File consistency
Direcotry in server A
=====================
#ll
-rw-r--r-- 1 root root 68186 Jun 19 15:30 aaa.txt
-rw-r--r-- 1 root root 68186 Jun 19 15:30 bbb.txt
-rw-r--r-- 1 root root 68186 Jun 19 15:30 ccc.txt
-rw-r--r-- 1 root root 68186 Jun 19 15:30 ddd.txt
"
Directory in server B
=====================
#ll
-rw-r--r-- 1 root root 68186 Jun 19 15:30 Ora_aaa.txt
-rw-r--r-- 1 root root 68186 Jun 19 15:30 Ora_bbb.txt
-rw-r--r-- 1 root root 68186 Jun 19 15:30 Ora_ccc.txt
-rw-r--r-- 1 root root 68186 Jun 19 15:30 Ora_ddd.txt
"
Some files will be appended to these directories time by time .
The files size , date and no. of files in these directories should be the same ( except the file name , the files name in server B are begins with Ora_ )
Now , I would like to make sure the files in these two directories are the same and no file is missing , so I would like to regularly check the files is the same or not so that I can take action to correct it immediately .
can you advise the script to check the files in it are the same , eg. check the files regularly ( 4 hrs ) , if any files is missing then notify me so that I can take action to correct it .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2009 08:29 PM
07-05-2009 08:29 PM
Re: File consistency
So, let's assume server B trusts server A via ssh keys (you can choose to trust via .rhosts but I advise strongly against it)
OKflag=0
ran=$RANDOM
TMPDIR=/tmp/tempfile.${ran}
mkdir $TMPDIR
cd /my/directory/path
for file in `ls -1`
do
scp server_B:/my/directory/path/Ora_${file} $TMPDIR
r=${?}
if [ $r -ne 0 ]
then
echo "Do something ${file} is missing on server B"
OKflag=1
fi
diff /my/directory/path/${file} $TMPDIR/Ora_${file} > /dev/null
rr=${?}
if [ $rr -ne 0 ]
then
echo "Do some other thing: $file is different on server B"
OKflag=2
fi
rm $TMPDIR/$Ora_{file}
done
if [ $OKflag -eq 0 ]
then
echo "Everything checked out fine at `date`"
fi
Hope this helps
Beware of syntax and typographical errors as the script was not tested in any unix platform.
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2009 10:09 PM
07-05-2009 10:09 PM
Re: File consistency
it works fine , for your method , sorry to have two more requirements .
1) as there are so many files in the directoies , it is not possible to copy all files to compare , can advise if only compare the file that created in a certain peroid of time ( eg. 4 hrs / 8 hrs ) what can i do ?
p.s assume the file creation date are the name .
2) can advise if I also want to compare the file size ( to make sure the file consistency ) , is it possible ?
thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2009 10:20 PM
07-05-2009 10:20 PM
Re: File consistency
You can use scp/rcp to achive the above task
Thanks
Jitesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2009 10:22 PM
07-05-2009 10:22 PM
Re: File consistency
You can create a reference file and only do files that are newer than that file.
If you do "ll -t", you can just stop when you see that file. (Or you can remember the time and do complex date arithmetic to see if newer.)
>2) I also want to compare the file size (to make sure the file consistency)?
From the ll(1) output, you can compare the sizes too.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2009 10:30 PM
07-05-2009 10:30 PM
Re: File consistency
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2009 01:12 AM
07-06-2009 01:12 AM
Re: File consistency
If you do "ll -t", you can just stop when you see that file. (Or you can remember the time and do complex date arithmetic to see if newer.) " --->>
sorry , I am not too unstandard what you mean to use "ll -t" to compare the time ? maybe I state more , what I would like is to compare the files that created within 4 hrs because there are too many files in server B , it is not possible to copy , can advise what can i do ? thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2009 03:29 AM
07-06-2009 03:29 AM
Re: File consistency
Every 4 hours you touch a file. Then you use the previous filename/time to stop looking.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2009 06:39 AM
07-06-2009 06:39 AM
Re: File consistency
you are on serverB:
touch /var/tmp/4hours_marker
...wait 4 hours or a little less
you are on serverA:
OKflag=0
ran=$RANDOM
TMPDIR=/tmp/tempfile.${ran}
mkdir $TMPDIR
ssh serverB "find /my/directory/path -newer /var/tmp/4hours_marker > /tmp/filelist; touch /var/tmp/4hours_marker"
ssh serverB "scp `cat /tmp/filelist` serverA:/$TMPDIR"
cd /my/directory/path
for file in `ls -1`
do
if [ -a Ora_${file} ]
then
#file exists, compare it to the local file
diff /my/directory/path/${file} $TMPDIR/Ora_${file} > /dev/null
rr=${?}
if [ $rr -ne 0 ]
then
echo "Do something: $file is different on server B"
OKflag=2
fi
else
echo "${file} is missing on serverB. Do something"
OKflag=1
fi
diff /my/directory/path/${file} $TMPDIR/Ora_${file} > /dev/null
rr=${?}
if [ $rr -ne 0 ]
then
echo "Do something: $file is different on server B"
OKflag=2
fi
done
if [ $OKflag -eq 0 ]
then
echo "Everything checked out fine at `date`"
fi
rm -r $TMPDIR
I know there are holes in this procedure, most important of which is lack of extensive error checking but nature of this forums is to guide you down the path. I hope my script helps you wind the way, on which you can build your own script with all the error handling and else.
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2009 10:28 PM
07-06-2009 10:28 PM
Re: File consistency
I tried your method
ssh serverB "find /my/directory/path -newer /var/tmp/4hours_marker > /tmp/filelist; touch /var/tmp/4hours_marker" .
I tried it but in do not create 4hours_marker file , it seems the command have error , if I just want to find the files created in 4 hours , how can i do it ? thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2009 12:42 AM
07-07-2009 12:42 AM
Re: File consistency
What had an error? The touch didn't create the file? Any error messages?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2009 10:21 PM
07-07-2009 10:21 PM
Re: File consistency
for your latest program , does the -newer mean only compare the newer files so I need to setup a crontab job to run it in every 4 hour ? if yes , can advise if I want the program can be run at anytime to check the files in past 4 hours ( not only the newer file ) , what can i do ? thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2009 12:30 AM
07-08-2009 12:30 AM
Re: File consistency
Yes.
>if I want the program can be run at anytime to check the files in past 4 hours (not only the newer file), what can I do?
Then you need to do date arithmetic to invoke touch. Or use perl. Or possibly gnu find that allows minutes in the -mtime.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2009 11:12 PM
07-08-2009 11:12 PM
Re: File consistency
Then you need to do date arithmetic to invoke touch. Or use perl. Or possibly gnu find that allows minutes in the -mtime. -->
can you please advise how to do it ? thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2009 11:26 PM
07-08-2009 11:26 PM
Re: File consistency
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2009 11:33 PM
07-08-2009 11:33 PM
Re: File consistency
Rather than copy the files back for comparison , is it possible to export the files to a list , then compare the lists in both servers , because copy the files back to local server , it seems increase the network traffic , can advise what can i do ? thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2009 02:54 AM
07-09-2009 02:54 AM
Re: File consistency
It's called hand waving, you are suppose to give up. ;-) Or manually enter the touch time for 4 hours ago.
(I personally would just write a C program to subtract 4 hours.)
>date arithmetic to invoke touch.
I don't know if Clay's date script will do minutes?
Some threads that mention it and other time manipulation with perl:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=951459
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1048731
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1120611
Gnu find:
http://hpux.connect.org.uk/hppd/hpux/Gnu/findutils-4.4.2/