Question on sync 2 folders with checking files' modify date


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Question on sync 2 folders with checking files' modify date
# 1  
Old 10-29-2013
Question on sync 2 folders with checking files' modify date

Hi Linux Community

I would like to ask about how to compare files in deferent server with date.
Those A and B servers has the same folder, I have write a sample script to "ls" both folders and "diff" them, and then "rsync" the missing files.
It was running well, both A and B are sync, until one day someone updated/modified a file on A, my sample script cannot detect it and havnt sync it to B.

Is there anyway to sync folders with file modify date between 2 servers?

Thanks.
# 2  
Old 10-30-2013
That is what rsync does by default (check on mod-time + size, -c option causes checksum verification).

There are a number of options to control features like remove files on dest that don't exist on source and the like.
# 3  
Old 10-30-2013
Hi Chubler_XL

Thanks for the reply, but do you mean "rsync" the hold folder?

Because there are many files in the folder, directly "rsync" the hold folder would take a long time, and the problem is, sometimes user will update on A, sometimes user will update on B, sorry I havnt mention this.

---------- Post updated at 01:06 PM ---------- Previous update was at 01:02 PM ----------

I tried " if [ file1 -nt root@B:file2 ]; then ", but the result is not good, it can't detect which one is new.
seems this method can only compare 2 local files, but not remotely...

Last edited by lunaticdawn; 10-30-2013 at 05:30 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to copy files/folders and show the files/folders?

Hi, So i know we use cp -r as a basic to copy folders/files. I would like this BUT i would like to show the output of the files being copied. With the amazing knowledge i have i have gone as far as this: 1) find source/* -exec cp -r {} target/ \; 2) for ObjectToBeCopied in `find... (6 Replies)
Discussion started by: Imre
6 Replies

2. Solaris

Client does not sync date with ntp servers

We had a network problem a couple of days before that caused 1 interface to down and up. But today I have noticed that our date is wrong, our system have 4 servers and the other 3 are OK. I used <date> command, the result is: Fri Jan 2 17:57:55 ICT 1970 I have tried set date to be the same as... (3 Replies)
Discussion started by: salvation3103
3 Replies

3. Shell Programming and Scripting

Checking the total size of all files from a particular date

Hi I have some set of files for a particular date. What is the command that I need to put in for finding the total size of all the files for that particular date. The following command is fetching me the size of all individual files seperately du -h *20101010* 16M file1.20101010 120K... (10 Replies)
Discussion started by: bobby1015
10 Replies

4. UNIX for Dummies Questions & Answers

Searching for folders/parent folders not files.

Hello again, A little while back I got help with creating a command to search all directories and sub directories for files from daystart of day x. I'm wondering if there is a command that I've overlooked that may be able to search for / write folder names to an output file which ideally... (2 Replies)
Discussion started by: Aussiemick
2 Replies

5. UNIX for Dummies Questions & Answers

mv folders/files without changing modified date?

Hi all, I'm using Red Hat Linux and want to move some folders and files around but not change the modified date. Is this possible? I know cp has a -p flag which seems to do what I want, but this is a large volume of data so copying and deleting would not be feasible. (13 Replies)
Discussion started by: Annorax
13 Replies

6. Solaris

Time and Date Sync between 2 Sol boxes

I have 2 sol 10 OS boxes in replication and there is a 6 minutes time difference in GMT zone. How I can sync? they are not on public network. (2 Replies)
Discussion started by: chandravadrevu
2 Replies

7. Shell Programming and Scripting

Question on reading dates in folders/files

Hi All, I have some folder that are named "FOLDERYYYYMM". I'm trying to piece together a .sh script that will look for the folder with the date. How can I get shell to see the date? (3 Replies)
Discussion started by: bbbngowc
3 Replies

8. UNIX for Advanced & Expert Users

how to sync remote folders without overwriting

Hi, I need to sync 2 remote folders so i setup with rsync which is working very fine. But, there comes another requirement to maintain multiple versions of files on destination (NOT to overwrite the destination file). If there is difference between source file and destination file, it must... (2 Replies)
Discussion started by: prvnrk
2 Replies

9. Shell Programming and Scripting

sync remote folders

Hi, I need to sync 2 remote folders so i setup with rsync which is working very fine. But, there comes another requirement to maintain multiple versions of files on destination (NOT to overwrite the destination file). If there is difference between source file and destination file, it must... (0 Replies)
Discussion started by: prvnrk
0 Replies
Login or Register to Ask a Question