Reputation: 125
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?
Upvotes: 3
Views: 1090
Reputation: 141877
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.
Upvotes: 3
Reputation: 473
Use lutimes
instead. See man lutimes
or http://www.gnu.org/software/libc/manual/html_node/File-Times.html
Upvotes: 1