20

How can I copy a file using SCP while preserving ctime (modification time)?

I have a folder on my Mac (OS 10.8), and the results of ls -l and ls -lc are the same.

$ ls -l
total 0
drwxr-xr-x  9 elliott  staff  306 Mar 24 21:24 Day1b
$ ls -lc
total 0
drwxr-xr-x  9 elliott  staff  306 Mar 24 21:24 Day1b

Then I copy it to a remote server (Linux), with -p to preserve timestamps.

$ scp -pr Day1b/ [email protected]:/

Now on the remote server, the ctime is changed to the current date.

# ls -l
total 00
drwxr-xr-x  3 elliott elliott 4096 Mar 24 23:24 Day1b/
# ls -lc
total 0
drwxr-xr-x  3 elliott elliott 4096 Mar 28 14:08 Day1b/

1 Answer 1

26

Modification time is mtime, not ctime. scp -p already preserves mtime.

ctime is the inode change time, updated every time the file itself is touched in any way – renamed, moved, chmodded, etc.

Generally there is no way to preserve it, as the OS does not provide any function for that, and even if it did, the very act of setting the ctime would be a change that would cause the ctime to be updated again.

In other words, ls -lc is useless for most purposes and one shouldn't worry about it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .