问题
Is it possible to change the atime
and mtime
of a symlink?
I am trying to change it using the utime()
function(C code) but instead it changes the time of destination files.
Also if I do
cp -dpr <src fldr> <<dest folder> (command line)
[The src folder contains different symlinks.] the symlinks at destination are created with current timestamp.
Doing a stat()
on the symlink will give me the timing of destination file (in C code) but if we fire a stat
command on command line it gives the timestamp of link(possibly it is using lstat
)
Any ideas?
回答1:
You can use touch with the -h
flag in bash to modify the mtime and atime of the symlink instead of the file it references:
touch -h somesymlink
You can use the -t
flag to specify a time to set it to, if you don't want to use the current time.
回答2:
Use lutimes
instead. See man lutimes
or http://www.gnu.org/software/libc/manual/html_node/File-Times.html
来源:https://stackoverflow.com/questions/10119242/softlinks-atime-and-mtime-modification