bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#18214: How to copy modification date with cp?


From: Bernhard Voelker
Subject: bug#18214: How to copy modification date with cp?
Date: Thu, 07 Aug 2014 14:34:29 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

tags 18214 notabug
close 18214
stop

On 08/07/2014 11:42 AM, Holger Klene wrote:
I'd like to copy photos from my harddrive to an external USB-drive for my 
parents. As
there are many more photos on my harddrive, that I don't want to copy to my 
parents, I
created a view folder with symbolic links that point exactly to the folders my 
parents
should get.

Now I copy the contents of the view-folder over to the USB-drive with:
cp -vLRu viewForMyParents usb

After some time, more folders are added and I plan on repeating the copy 
command to
update the usb-drive with the latest additions.

The problem is, all files and folders get a timestamp of the moment, when the 
copy took
place instead of the original files timestamp.

I reproduced the setup and took a screenshot (cp-error.png). Only that the tar 
did not
preserve the symbolic links inside test/myHardDrive/viewForMyParents/

My question is, how can I make cp not updating the timestamps to the moment of 
the copy
(e.g. 11:00) but instead let it copy the original files last modified (e.g. 
10:something)?

Thanks
Holger

PS: This is Kubuntu 14.04 with cp (GNU coreutils) 8.21

Thanks for the report, however this is not a bug but rather a question
about how to use cp(1). As your email opened a bug in our bugtracker,
I therefore mark this as not a bug.

Regarding the question, the answer is -p or --preserve=timestamps:

  $ cp --help
  ...
  -p                           same as --preserve=mode,ownership,timestamps
      --preserve[=ATTR_LIST]   preserve the specified attributes (default:
                                 mode,ownership,timestamps), if possible
                                 additional attributes: context, links, xattr,
                                 all

BTW: as you seem to want to repeat the syncing in future again,
I'd personally recommend using rsync(1) rather than cp(1).

Have a nice day,
Berny





reply via email to

[Prev in Thread] Current Thread [Next in Thread]