LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-19-2014, 09:21 PM   #1
ravisingh1
Member
 
Registered: Apr 2013
Location: Mumbai
Distribution: Ubuntu13.10
Posts: 291

Rep: Reputation: Disabled
copied & pasted: when is time stamp retained ?


I copy paste files from one place to other. Now, I'm in a doubt as when the time stamp (modification) is retained.

See, I tested in my laptop internal hdd. Here the time stamp is getting retained even if I copy paste from one partition to other!

I tested it with tablet. I connected the tablet with usb cable. Now if I copy & paste a file from tablet to laptop, the time stamp (modification) is not getting retained.

So, when is the time stamp retained & when it is not?
 
Old 06-20-2014, 04:44 AM   #2
Doc CPU
Senior Member
 
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Hi there,

Quote:
Originally Posted by ravisingh1 View Post
I copy paste files from one place to other. Now, I'm in a doubt as when the time stamp (modification) is retained.
as a rule of thumb: In strictly file-based operations, the file timestamp is retained if all file systems and handlers involved in the action support timestamps.

Quote:
Originally Posted by ravisingh1 View Post
See, I tested in my laptop internal hdd. Here the time stamp is getting retained even if I copy paste from one partition to other!
That's what I would expect.

Quote:
Originally Posted by ravisingh1 View Post
I tested it with tablet. I connected the tablet with usb cable. Now if I copy & paste a file from tablet to laptop, the time stamp (modification) is not getting retained.
How is the tablet being accessed? As a USB storage device mounted to the host file system? Probably not, because that would require the host to read and write the tablet's memory directly on sector level. I rather guess the tablet has some kind of server running (FTP or something like Samba), and the USB link is treated like a network connection.

And yes, by copying files from one machine to another, you sometimes lose timestamps, the copy gets timestamped with the moment of copying. I'm experiencing this here, too: Two Linux-based machines, say A and B, both running Samba with a few shares. If I copy from A to B, timestamps are preserved; if I copy from B to A, timestamps are refreshed to the moment of copying. I still haven't found out what the reason is, but maybe someone else can supply additional information.

[X] Doc CPU
 
1 members found this post helpful.
Old 06-20-2014, 07:59 AM   #3
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,886
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
Copying from one physical disk or partition to another will change the timestamp. And clearly copying to another entire system matches this criteria.

Copying a file within the scope of an existing disk, typically will retain the timestamp.

I believe that if you have one disk but with two or more data partitions, if you copy/paste from one partition to another, it will change the timestamp.
 
Old 06-20-2014, 08:28 AM   #4
Doc CPU
Senior Member
 
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Hi there,

Quote:
Originally Posted by rtmistler View Post
Copying from one physical disk or partition to another will change the timestamp.
that's against experience: If I copy to or from a USB storage (HDD, pen drive, SD card), the timestamp is copied "as is". Which makes sense, because the file contents isn't modified, so why would the modification date change?

Quote:
Originally Posted by rtmistler View Post
I believe that if you have one disk but with two or more data partitions, if you copy/paste from one partition to another, it will change the timestamp.
You believe wrong. I'm not denying that there may be circumstances where you're right. But usually, timestamps are preserved in a copy/move operation (which is what C&P in a file manager actually does).

Only copying "through Samba" across different machines sometimes changes the modification timestamp. But even then, not always. Probably a side effect of a particular Samba configuration option.

[X] Doc CPU
 
1 members found this post helpful.
Old 06-20-2014, 09:19 AM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,846

Rep: Reputation: 8009Reputation: 8009Reputation: 8009Reputation: 8009Reputation: 8009Reputation: 8009Reputation: 8009Reputation: 8009Reputation: 8009Reputation: 8009Reputation: 8009
Quote:
Originally Posted by ravisingh1 View Post
I copy paste files from one place to other. Now, I'm in a doubt as when the time stamp (modification) is retained.

See, I tested in my laptop internal hdd. Here the time stamp is getting retained even if I copy paste from one partition to other! I tested it with tablet. I connected the tablet with usb cable. Now if I copy & paste a file from tablet to laptop, the time stamp (modification) is not getting retained. So, when is the time stamp retained & when it is not?
You posted what is (essentially), this same question twice; your other thread was reported. Since you don't tell us what kind of tablet you're using, it's hard to offer options. Some tablets have microsd cards, and there are MANY Android utilities that will let you copy files from internal memory to the SD card. From there, put the card into your laptop, and you may have more options for copying.

That said, have you tried reading the man page on the cp command? Pay particular attention to the "-p" and "-a" flags:
Code:
-p     same as --preserve=mode,ownership,timestamps
-a, --archive
              same as -dR --preserve=all
Did you try that?
 
Old 06-20-2014, 09:59 AM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,786

Rep: Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216
Quote:
Originally Posted by ravisingh1 View Post
I copy paste files from one place to other. Now, I'm in a doubt as when the time stamp (modification) is retained.
That is entirely up to the application doing the copy/move operation. The only time that the timestamp would be retained by default is a simple rename operation within the same filesystem. That operation does not create a new inode, and the mtime and atime fields in the inode would not be changed. For every other case, a new inode is created, and it will initially have all its timestamps set to the current time. To preserve the original timestamps, the application would need to use one of the utime(2) system calls to set those times.

You can see this in action by running the mv command under strace and move a file to a different filesystem. The mv command tries to preserve the semantics of a simple rename operation, so one of the last things it does is a utimensat() call to set the timestamps on the destination to match those of the source.
 
Old 06-20-2014, 10:26 AM   #7
ravisingh1
Member
 
Registered: Apr 2013
Location: Mumbai
Distribution: Ubuntu13.10
Posts: 291

Original Poster
Rep: Reputation: Disabled
Question

Quote:
Originally Posted by TB0ne View Post
Some tablets have microsd cards, and there are MANY Android utilities that will let you copy files from internal memory to the SD card. From there, put the card into your laptop, and you may have more options for copying.
O.K., SD card ! That may be a way. I've to check.

Quote:
Originally Posted by TB0ne View Post
That said, have you tried reading the man page on the cp command? Pay particular attention to the "-p" and "-a" flags:
Code:
-p     same as --preserve=mode,ownership,timestamps
-a, --archive
              same as -dR --preserve=all
Did you try that?
No, I havent checked cp command. The reason is I feel command line won't work in case of my tablet. See I've a thread here. There I've written that tar command isn't working. The tablet is mounted via mtp (using USB cable) or something like that & not as USB mass storage like pen drive or external hdd. So I feel command line won't work.

My tablet is Asus fonepad7 (android).

Last edited by ravisingh1; 06-20-2014 at 10:30 AM.
 
Old 06-20-2014, 10:48 AM   #8
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,846

Rep: Reputation: 8009Reputation: 8009Reputation: 8009Reputation: 8009Reputation: 8009Reputation: 8009Reputation: 8009Reputation: 8009Reputation: 8009Reputation: 8009Reputation: 8009
Quote:
Originally Posted by ravisingh1 View Post
O.K., SD card ! That may be a way. I've to check.

No, I havent checked cp command. The reason is I feel command line won't work in case of my tablet. See I've a thread here. There I've written that tar command isn't working. The tablet is mounted via mtp (using USB cable) or something like that & not as USB mass storage like pen drive or external hdd. So I feel command line won't work.

My tablet is Asus fonepad7 (android).
Yes, that's the duplicate thread that was reported. And if all you have is the MTP, then you have two choices:
  • Manually change dates/times after you copy
  • Learn to live with it
 
Old 06-20-2014, 10:55 AM   #9
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
There is a difference depending on HOW you copy files.

If you use "cp" to copy, the modification date is preserved. The creation date (which is misnamed) is actually an "inode modification date" and that always gets the current date.

If you copy with a GUI, then all dates may be lost.

If you are "copying" via a network style connection you also lose the dates.

If you "copy/paste" you are going through something other than the systems copying function.
 
Old 06-21-2014, 02:48 AM   #10
Doc CPU
Senior Member
 
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Hi there,

to clear things up a little, I made a few tests myself, and to my surprise I found that I partly have to correct my own statements.

Quote:
Originally Posted by jpollard View Post
There is a difference depending on HOW you copy files.
Yes, definitely. I considered the two methods a) cp from the command line and b) drag&drop from a GUI file manager, which is Caja in my system (much like Gnome's Nautilus). I copied a few files from a USB HDD to the internal drive.

Quote:
Originally Posted by jpollard View Post
If you use "cp" to copy, the modification date is preserved. The creation date (which is misnamed) is actually an "inode modification date" and that always gets the current date.

If you copy with a GUI, then all dates may be lost.
Actually, it's exactly the other way round. All files copied with 'cp' got a fresh modification date, except with the -p switch.
The files copied with Caja, however, retained their modification date. But you can see that while copying is still in progress, the partial file also has a new timestamp, which is adjusted to the original's at the end.

Quote:
Originally Posted by jpollard View Post
If you are "copying" via a network style connection you also lose the dates.
Sometimes, but not always. And I still haven't found the time to take the Samba configuration apart on the two machines showing different behavior depending on the direction of the copying action.

Quote:
Originally Posted by jpollard View Post
If you "copy/paste" you are going through something other than the systems copying function.
I don't think so. C&P in a GUI file manager is nothing else than a copy/move operation delayed until the 'paste' action.

[X] Doc CPU
 
1 members found this post helpful.
Old 06-21-2014, 07:51 AM   #11
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
It depends on weather the date is set after the copy.
 
Old 06-22-2014, 02:58 AM   #12
ravisingh1
Member
 
Registered: Apr 2013
Location: Mumbai
Distribution: Ubuntu13.10
Posts: 291

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
That said, have you tried reading the man page on the cp command? Pay particular attention to the "-p" and "-a" flags:
Code:
-p     same as --preserve=mode,ownership,timestamps
-a, --archive
              same as -dR --preserve=all
Did you try that?
Yes TBOne, that issue of copying photos from tablet to laptop by retaining the time stamp is solved. As this point doesn't go well with this thread, please have a look at that thread.

Quote:
Originally Posted by TB0ne View Post
And if all you have is the MTP, then you have two choices:
  • Manually change dates/times after you copy
  • Learn to live with it
You thought in a right direction by mentioning MTP. Yes it worked not with MTP but with gphoto2.
 
Old 06-22-2014, 11:58 AM   #13
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,846

Rep: Reputation: 8009Reputation: 8009Reputation: 8009Reputation: 8009Reputation: 8009Reputation: 8009Reputation: 8009Reputation: 8009Reputation: 8009Reputation: 8009Reputation: 8009
Quote:
Originally Posted by ravisingh1 View Post
Yes TBOne, that issue of copying photos from tablet to laptop by retaining the time stamp is solved. As this point doesn't go well with this thread, please have a look at that thread.
No thanks, because again you should not post the same question more than once. Read the LQ rules.
Quote:
You thought in a right direction by mentioning MTP. Yes it worked not with MTP but with gphoto2.
...and since gphoto2 uses MTP, and if you had read the man pages to start with, you'd have had the solution earlier.
 
  


Reply

Tags
android, back-up, timestamp


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
[SOLVED] Do special vi chars lose meaning if copied and pasted in script? Batistuta_g_2000 Linux - Newbie 8 02-20-2013 05:49 AM
copied files in nfs does not show the right time-stamp kingston Linux - Newbie 3 03-04-2011 12:49 AM
Clipboard content get pasted randomly ( Suse & Ubuntu ) hyapadi Linux - Laptop and Netbook 6 07-09-2006 05:20 AM
Time stamp Kalyani1 Linux - Software 0 11-07-2005 02:58 PM
Time stamp in Samba is 11 hours behind time stamp in Linux Linh Linux - General 3 09-04-2003 12:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:55 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
Open Source Consulting | Domain Registration