LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-03-2011, 12:09 AM   #1
kingston
Member
 
Registered: Mar 2008
Location: Bengaluru, India
Distribution: RHEL 5.5, Solaris 5.10
Posts: 215
Blog Entries: 1

Rep: Reputation: 21
copied files in nfs does not show the right time-stamp


Hi all
I have two systems running on linux. system one is running with RHEL 5.4/X86_64 hardware, system two is running with RHEL 5.3/i686 hardware. One filesystem is shared from system two and mounted as NFS on system one.
Now when i do a copy from local filesystem to the NFS share from system one,it shows as follows
Quote:
-rw-r--r-- 1 xkinved rbak1 30 Mar 3 2011 king
But if i do copy with -p option then it shows right time stamp. Both machines are running with slight(minutes) different in time. Does this could be cause for this problem? The problem is happening while i do FTP from some other machines too.

Need your guidance.
 
Old 03-03-2011, 06:48 AM   #2
ryoken31
LQ Newbie
 
Registered: Apr 2007
Location: Ontario
Posts: 6

Rep: Reputation: 2
I would imagine that when you copy a file you are getting a time stamp with the date the file was copied. This is because when you copy a file you essentially create a "new" file, write the contents of the original file to it and then rename it. The new copy was created today, so the times tamp shows today.

According to the man pages for cp the "-p" option allows you to preserve the original file attributes (like the time stamp) when you copy a file. Therefore, if you use this option when copying files from one place to another it should preserve the timestamps of the original file.
 
Old 03-03-2011, 03:55 PM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
From my experience, in some cases, stat and ls will return only the date portion of the timestamp for files whose date seems to be in the future. I created my "Poor-Man's NTP Client" to synchronize system time/date between a NFS server master and NFS client slave, partly to solve this problem.
Code:
#! /bin/sh
#
#       Poor-Mans NTP client
#
#       Set system date/time from NFS-connected file time-stamp
#       Allows immediate date setting to within 1-second synchronization
#
#       Write to a file mounted on an NFS filesystem. Immediately read back the
#       file's timestamp, and use the result to set the system clock.
#
TIMESTAMP_FILE='/mnt/nfsserver/time.file'

#       Some versions of stat will report only 'Date' portions of file timestamps if
#       the file has a timestamp in the future, relative to the existing system time.
#       We make sure that all timestamps will appear to be in the past by temporarily
#       setting the system time to near maximum possible

date -s '31 Dec 2037' > /dev/null
echo "This file for rough setting of time on mounted hosts" > $TIMESTAMP_FILE
date -s "`stat -c "%z" $TIMESTAMP_FILE`" > /dev/null
echo "System time: ";  date
I use this to set the system clock on boot of embedded systems that do not have their own non-volatile real time clock. It could also be used to get your NFS server & client(s) sufficiently synch'd that your filesystem timestamp issues go away.

--- rod.
 
Old 03-04-2011, 12:49 AM   #4
kingston
Member
 
Registered: Mar 2008
Location: Bengaluru, India
Distribution: RHEL 5.5, Solaris 5.10
Posts: 215
Blog Entries: 1

Original Poster
Rep: Reputation: 21
thanks for both of you for your comments and help. I will soon implement theNbomr's suggestion and revert back.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
time stamp of files ZAMO Linux - General 1 12-17-2008 05:45 AM
Files copied ... desktop settings don't show up? SlowCoder Linux - Desktop 2 12-11-2007 08:32 PM
Archiving files using a time stamp. HunterColt22 Programming 3 06-11-2007 01:29 AM
Time stamp in Samba is 11 hours behind time stamp in Linux Linh Linux - General 3 09-04-2003 12:44 PM
Remove files by time stamp evione Linux - Newbie 1 07-15-2003 09:35 AM


All times are GMT -5. The time now is 03:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration