Timestamp comparison of 2 files present in 2 different servers


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Timestamp comparison of 2 files present in 2 different servers
# 1  
Old 08-27-2008
Timestamp comparison of 2 files present in 2 different servers

Hi,

I have 2 different log servers and logs are stored in both of them at varied times. Those servers have same files stored at different times. I want to retrieve the latest of the log files that are stored inthe servers. Say "file.log" is present on both servers, i want to check which of it is latest and retrieve it for my analysis.

As of now i have a script to FTP the "file.log" from both the servers and store at one location, but how can i know which of it is latest while the file is present in the server itself.

With my script i am able to FTP the file from both locations and store it at one location in my log server and then i am checking the timestamp by following statement, but it will always give temp_fms02 directory file as latest as it is being FTPied after the first one

if [[ /temp_fms01/icc-2-19-0.log -ot /temp_fms02/icc-2-19-0.log ]]
then
use temp_fms01 file
else
use temp_fms01 file
fi


Pls let me know if there is any other way to check which of the locations is having the latest file and directly FTP it and use it.

Any help or suggesstions are highly appreciated.

Thanks!
# 2  
Old 08-27-2008
ftp is a bit cumbersome to script, so if you could switch to scp or rsync that might be the easiest solution. With ftp I guess you would have to issue a remote ls and parse the result, and hope the file isn't updated on either server while you figure things out on your end.
# 3  
Old 08-27-2008
The file is being updated continuously on one of the servers! I want to pick the one which is being updated and it doesn't matter if the update process is still going on in the background!
# 4  
Old 08-27-2008
you should read the manuals for your ftp program to check if there is a way to preserve times.

also, the "-ot" option, well, in the manual page of the box im stading now, it dosnt specify if its creation time, or modification time.

if you have gnu date, it has a switch to return the modification time in seconds since epoch.
if you dont have it, i found a 4 lines c app that does exactly that. (it saved my day, when i needed to check time since last modification of a log file in an ancient sunOS)
general pastebin - modtime - post number 1186288

in my opinion, you should switch to scp (which can preserve time stamps)
maybe, copying the 2 files to only use one is not the best.
you could also use a HERE document with ssh to get the modification time, and only scp the one you need.
on this subject you could also use "expect"
which is a scripting language made specificly to manage interactive programs within a script.
Expect - Expect - Home Page
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unzip all the files with subdirectories present and append a part of string from the main .zip files

Hi frnds, My requirement is I have a zip file with name say eg: test_ABC_UH_ccde2a_awdeaea_20150422.zip within that there are subdirectories on each directory we again have .zip files and in that we have files like mama20150422.gz and so on. Iam in need of a bash script so that it unzips... (0 Replies)
Discussion started by: Ravi Kishore
0 Replies

2. Shell Programming and Scripting

Checking in a directory how many files are present and basing on that merge all the files

Hi, My requirement is,there is a directory location like: :camp/current/ In this location there can be different flat files that are generated in a single day with same header and the data will be different, differentiated by timestamp, so i need to verify how many files are generated... (10 Replies)
Discussion started by: srikanth_sagi
10 Replies

3. Shell Programming and Scripting

File Comparison: Print Lines not present in another file

Hi, I have fileA.txt like this. B01B02 D0011718 B01B03 D0012540 B01B04 D0006145 B01B05 D0004815 B01B06 D0012069 B01B07 D0004064 B01B08 D0011988 B01B09 D0012071 B01B10 D0005596 B01B11 D0011351 B01B12 D0004814 B01C01 D0011804 I want to compare this against another file (fileB.txt)... (3 Replies)
Discussion started by: genehunter
3 Replies

4. Shell Programming and Scripting

Comparison of timestamp on ftp

Hello Need help with shell script There is are files on my ftp. They overwriting every hour from other places. ls -la /home/ftp/ -rw-r--r-- 1 ftp nogroup 2296 2012-08-11 12:59 G1.zip -rw-r--r-- 1 ftp nogroup 6676 2012-08-11 13:00 KRT1.zip -rw-r--r-- 1 ftp nogroup 5169... (3 Replies)
Discussion started by: ck80
3 Replies

5. Shell Programming and Scripting

Identifying files with a timestamp greater than a given timestamp

I need to be able to identify files with file timestamps greater than a given timestamp. I am using the following solution, although it appears to compare files at the "seconds" granularity and I need it at the milliseconds. When I tested my solution, it missed files that had timestamps... (3 Replies)
Discussion started by: nkm0brm
3 Replies

6. Shell Programming and Scripting

Comparison of a timestamp and mtime of a file

Hi, I am a beginner in shell scripting. Could any one help me out for below requirement. Its bit urgent. Problem scenario: 1) I have a predefined timestamp (Ex. 2011-03-010 10:10:20) 2) And I have files in a directory starting with 'a' (Ex. a_123.txt, a_124.txt) Expected solution: I... (1 Reply)
Discussion started by: itzsamz
1 Replies

7. UNIX for Dummies Questions & Answers

Timestamp comparison

How do I compare 2 timestamps (ie... if 2008-02-13 10:48:58.502075 gt 2008-12-15 16:00:00.000000) (4 Replies)
Discussion started by: auzark
4 Replies

8. Shell Programming and Scripting

Timestamp comparison

Hi all, below is my sample log file 02.20.38 .CASH_I_0069 RPM_RUN_DISTRIBUTION RPM_RUN_DISTRIBUTION 0001 1987 Started at 02.19.11 at node IEREDS17, Pid = 00492972 02.50.39 .CASH_I_0054 RPM_RUN_DISTRIBUTION RPM_RUN_DISTRIBUTION 0001 1987 Completed at 02.49.13, code: 00000000 at node IEREDS17,... (1 Reply)
Discussion started by: zainravi
1 Replies

9. UNIX for Dummies Questions & Answers

override the system date-timestamp on the Unix servers

I am looking for a tool that allows us to override the system date-timestamp on the Unix servers so that we can perform regression tests using the same set of scripts and data. CDS is an example of a system where the logic is very date/time dependent. It would make regression testing much easier... (5 Replies)
Discussion started by: DavidH
5 Replies

10. UNIX for Advanced & Expert Users

File timestamp issue on HP servers

Hi All , I have a file which gets updated by a korn job daily . The file gets the latest timestamp on everyrun. But of late i have observed that the file timestamp gets modified to a older date ( Oct 25 2006 ) at some point in time of the day. This change has nothing to do with the job which... (5 Replies)
Discussion started by: siddaonline
5 Replies
Login or Register to Ask a Question