LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 04-09-2022, 09:29 PM   #1
iammike2
Member
 
Registered: Oct 2018
Location: SE-Asia/Europe
Distribution: Raspi OS bullseye-arm64
Posts: 69

Rep: Reputation: Disabled
Cp doesn't copy timestamps but MC does


Need your help again.

I am copying files with CP from my Raspberry PI to my NAS.

PI is ext4
NAS is btrfs

Ps: NAS dir is the mount point for my NAS

None of the following commands is copying the timestamps over

Code:
cp -i -a /home/pi/files/*.txt /home/pi/Downloads/NAS/files
cp -i -p /home/pi/files/*.txt /home/pi/Downloads/NAS/files
cp -i --preserve=timestamps /home/pi/files/*.txt /home/pi/Downloads/NAS/files
But if I select the files in MC (Midnight Commander) and copy them over (same files / same dirs) the timestamp is kept

Any ideas???

Os: raspios-bullseye-arm64 (fully up to date)

Last edited by iammike2; 04-09-2022 at 09:32 PM.
 
Old 04-09-2022, 10:41 PM   #2
mrmazda
LQ Guru
 
Registered: Aug 2016
Location: SE USA
Distribution: openSUSE 24/7; Debian, Knoppix, Mageia, Fedora, others
Posts: 5,808
Blog Entries: 1

Rep: Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066
Quote:
Originally Posted by iammike2 View Post
Any ideas???
Use rsync instead of cp?
 
Old 04-09-2022, 11:29 PM   #3
iammike2
Member
 
Registered: Oct 2018
Location: SE-Asia/Europe
Distribution: Raspi OS bullseye-arm64
Posts: 69

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by mrmazda View Post
Use rsync instead of cp?

Good idea yes will try that, but then the question remains why is CP not copying timestamps?

Edit: Yes Rsync (-v -a -h) does transfer the timestamps!

Last edited by iammike2; 04-09-2022 at 11:35 PM.
 
Old 04-10-2022, 12:18 AM   #4
lvm_
Member
 
Registered: Jul 2020
Posts: 925

Rep: Reputation: 337Reputation: 337Reputation: 337Reputation: 337
How the NAS is mounted?

Last edited by lvm_; 04-10-2022 at 12:28 AM.
 
Old 04-10-2022, 12:26 AM   #5
mrmazda
LQ Guru
 
Registered: Aug 2016
Location: SE USA
Distribution: openSUSE 24/7; Debian, Knoppix, Mageia, Fedora, others
Posts: 5,808
Blog Entries: 1

Rep: Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066
Quote:
Originally Posted by lvm_ View Post
Because you didn't tell it so
Looks to me like he did so:
Code:
cp -i -a ...
unless -i overrides, supercedes or disables -a.
 
Old 04-10-2022, 03:04 AM   #6
iammike2
Member
 
Registered: Oct 2018
Location: SE-Asia/Europe
Distribution: Raspi OS bullseye-arm64
Posts: 69

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by lvm_ View Post
How the NAS is mounted?

Cifs.


Will mount as NFS and see if it changes the outcome for CP


But Rsync works!
 
Old 04-10-2022, 03:05 AM   #7
iammike2
Member
 
Registered: Oct 2018
Location: SE-Asia/Europe
Distribution: Raspi OS bullseye-arm64
Posts: 69

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by mrmazda View Post
Looks to me like he did so:
Code:
cp -i -a ...
unless -i overrides, supercedes or disables -a.

Will try with removing -i!



(But why should -i override, it's AFAIK for interactive - ask before overwrite)

Edit:

removing -i only leaving -a no change
removing -i only leaving -p no change
removing -i only leaving --preserve=timestamps no change
change --preserve=timestamps to =all no change

Last edited by iammike2; 04-10-2022 at 03:42 AM.
 
Old 04-10-2022, 05:13 AM   #8
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,790

Rep: Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201
Quote:
Originally Posted by iammike2 View Post

Code:
cp -i -a /home/pi/files/*.txt /home/pi/Downloads/NAS/files
cp -i -p /home/pi/files/*.txt /home/pi/Downloads/NAS/files
cp -i --preserve=timestamps /home/pi/files/*.txt /home/pi/Downloads/NAS/files
All these should work, a -i does not make a difference.
Check what you cp is
Code:
type cp

Last edited by MadeInGermany; 04-10-2022 at 05:14 AM.
 
Old 04-10-2022, 09:09 PM   #9
iammike2
Member
 
Registered: Oct 2018
Location: SE-Asia/Europe
Distribution: Raspi OS bullseye-arm64
Posts: 69

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by MadeInGermany View Post
All these should work, a -i does not make a difference.
Check what you cp is
Code:
type cp

Code:
~ $ type cp
cp is /usr/bin/cp

~ $ which cp
/usr/bin/cp

Last edited by iammike2; 04-11-2022 at 02:28 AM.
 
Old 04-11-2022, 04:09 AM   #10
iammike2
Member
 
Registered: Oct 2018
Location: SE-Asia/Europe
Distribution: Raspi OS bullseye-arm64
Posts: 69

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by iammike2 View Post
Cifs.

Will mount as NFS and see if it changes the outcome for CP

But Rsync works!

Mount NAS as NFS and CP works with -a in preserving the timestamps


So concluding


Ext4 -> BTRFS -> Mounted as CIFS -> CP -a (not retaining timestamps)
Ext4 -> BTRFS -> Mounted as CIFS -> CP -p (not retaining timestamps)
Ext4 -> BTRFS -> Mounted as CIFS -> Rsync -v -a -h (retaining timestamps)
Ext4 -> BTRFS -> Mounted as NFS -> CP -a (retaining timestamps)
 
  


Reply



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
How to copy only the timestamps for files and folders??? MogaMoga Linux - General 6 04-01-2023 12:40 AM
Want to change how pasted files are named "(copy)," "(another copy)," "(3rd copy)" L a r r y Linux - Desktop 3 08-24-2013 03:39 PM
I don't understand why log timestamps are UTC but date command is local time Rogue45 Linux - Newbie 5 07-19-2013 03:39 PM
squid timestamps chamkila Linux - General 1 05-08-2003 08:59 AM
Timestamps Config Programming 2 04-22-2002 02:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:38 AM.

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