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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
06-19-2014, 09:21 PM
|
#1
|
Member
Registered: Apr 2013
Location: Mumbai
Distribution: Ubuntu13.10
Posts: 291
Rep: 
|
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?
|
|
|
06-20-2014, 04:44 AM
|
#2
|
Senior Member
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099
|
Hi there,
Quote:
Originally Posted by ravisingh1
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
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
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.
|
06-20-2014, 07:59 AM
|
#3
|
Moderator
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,961
|
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.
|
|
|
06-20-2014, 08:28 AM
|
#4
|
Senior Member
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099
|
Hi there,
Quote:
Originally Posted by rtmistler
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
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.
|
06-20-2014, 09:19 AM
|
#5
|
LQ Guru
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,787
|
Quote:
Originally Posted by ravisingh1
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?
|
|
|
06-20-2014, 09:59 AM
|
#6
|
Senior Member
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,827
|
Quote:
Originally Posted by ravisingh1
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.
|
|
|
06-20-2014, 10:26 AM
|
#7
|
Member
Registered: Apr 2013
Location: Mumbai
Distribution: Ubuntu13.10
Posts: 291
Original Poster
Rep: 
|
Quote:
Originally Posted by TB0ne
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
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.
|
|
|
06-20-2014, 10:48 AM
|
#8
|
LQ Guru
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,787
|
Quote:
Originally Posted by ravisingh1
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
|
|
|
06-20-2014, 10:55 AM
|
#9
|
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,908
|
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.
|
|
|
06-21-2014, 02:48 AM
|
#10
|
Senior Member
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099
|
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
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
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
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
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.
|
06-21-2014, 07:51 AM
|
#11
|
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,908
|
It depends on weather the date is set after the copy.
|
|
|
06-22-2014, 02:58 AM
|
#12
|
Member
Registered: Apr 2013
Location: Mumbai
Distribution: Ubuntu13.10
Posts: 291
Original Poster
Rep: 
|
Quote:
Originally Posted by TB0ne
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
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.
|
|
|
06-22-2014, 11:58 AM
|
#13
|
LQ Guru
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,787
|
Quote:
Originally Posted by ravisingh1
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.
|
|
|
All times are GMT -5. The time now is 11:22 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|