Operating System - Linux
1827158 Members
1990 Online
109716 Solutions
New Discussion

create a symbolic link with same timestamp as target

 
renarios
Trusted Contributor

create a symbolic link with same timestamp as target

Hi all,

I'm facing an issue with symbolic links and timestamps. It is not possible to change the timestamp of a symlink, but is there any way to create a symbolic link with same timestamp as the target file?

I really hope you can help me out!

Cheers,

Renarios

Nothing is more successfull as failure
4 REPLIES 4
Steven Schweda
Honored Contributor

Re: create a symbolic link with same timestamp as target

I know nothing, but I'd expect "touch" to be
the program to use. However, Google found:

http://www.nabble.com/Touch-symlink-td4093016.html

which seemed to be discouraging.


Why do you care?
renarios
Trusted Contributor

Re: create a symbolic link with same timestamp as target

Well, I've got a photo-gallery, which uses symlinks in a "sorted" mounpoint in stead of using the original unsorted mp.
Now all photo's in the gallery are displayed with the wrong timestamp (the timestamp of the symlinks) which is rather annoying.
I create the symlinks with a script and I'm considering using a 'date' function to change the system time before creating the link, but that's not the most beautiful solution.
I have searched for a solution before, but did not find the answer. I thought that maybe the gurus at itrc might could hand an/THE option/workaround/solution.

Cheers,

Renarios
Nothing is more successfull as failure
Ivan Ferreira
Honored Contributor

Re: create a symbolic link with same timestamp as target

As the symlink is anhoter file, I don't think that you could have the exact timestamp unless you "touch" the file.

Maybe another option, like hard links, or loop mounting the file system may help. ¿Have you considered an alternate solution to your requirement?
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
renarios
Trusted Contributor

Re: create a symbolic link with same timestamp as target

Yes, I've considered other methods, but that would implicitly double the storage.

So I finally found a disadvantage for Linux huh?

Well, since changing the timstamp of a symbolic link isn't an option, I guess hard links are the only option to do the trick.

Does anyone have a little script for lazy me to covert all existing symbolic links to hard ones?

Nothing is more successfull as failure