软链接的atime和修改的mtime [英] softlinks atime and mtime modification
问题描述
是否有可能修改的atime
和的mtime
符号链接的?
Is it possible to change the atime
and mtime
of a symlink?
我试图用改变它的 UTIME()
功能(C code),而是它改变了目标文件的时间。
I am trying to change it using the utime()
function(C code) but instead it changes the time of destination files.
另外,如果我做
cp -dpr <src fldr> <<dest folder> (command line)
[src文件夹中包含不同的符号链接]
在目的地的符号链接与当前时间戳创建。
[The src folder contains different symlinks.] the symlinks at destination are created with current timestamp.
做一个 STAT()
的符号链接会给我的目标文件的时间(在C code),但如果我们火统计
的命令行命令,它给出链接的时间戳(可能它是使用 LSTAT
)
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
)
任何想法?
推荐答案
您可以使用与在bash的 -h
标记触摸修改符号链接的mtime,并增加的atime而不是文件的它引用:
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
您可以使用 -t
标记指定的时间将其设置为,如果你不想使用当前时间。
You can use the -t
flag to specify a time to set it to, if you don't want to use the current time.
这篇关于软链接的atime和修改的mtime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!