Changing mtime of a symlink

Hello,
I've got a directory full of symlinks to some documents, and this directory
gets mirrored (by weex) onto an ftp server.

When deciding which files to transfer, weex looks at the modification
timestamp of the file in question. If that hasn't changed since the last
transfer, the file won't be sent.

My problem is that when one of the pointed-to files is modified, the mtime
of the symlink doesn't change accordingly. So I tried this to sync the
links' timestamps with their targets:

find . -type l -printf 'touch -r "%l" "%h/%f"\n' | sh

However, it seems that if used on a symlink, touch modifies the target, not
the link.

General question: How can the modification time of a symlink be set to an
arbitrary date?

Thanks,
robert
Robert Latest [ Fr, 02 November 2007 10:08 ] [ ID #1860551 ]

Re: Changing mtime of a symlink

On Nov 2, 2:08 pm, Robert Latest <boblat... [at] yahoo.com> wrote:
> Hello,
> I've got a directory full of symlinks to some documents, and this directory
> gets mirrored (by weex) onto an ftp server.
>
> When deciding which files to transfer, weex looks at the modification
> timestamp of the file in question. If that hasn't changed since the last
> transfer, the file won't be sent.
>
> My problem is that when one of the pointed-to files is modified, the mtime
> of the symlink doesn't change accordingly. So I tried this to sync the
> links' timestamps with their targets:
>
> find . -type l -printf 'touch -r "%l" "%h/%f"\n' | sh
>
> However, it seems that if used on a symlink, touch modifies the target, not
> the link.
>
> General question: How can the modification time of a symlink be set to an
> arbitrary date?
>
> Thanks,
> robert

Robert seems it is not supported by unix like kernals to change the
timestamp of symlink. Found discussion at the following link:
http://www.mail-archive.com/bug-coreutils [at] gnu.org/msg10849.h tml
ramesh.thangamani [ Fr, 02 November 2007 11:35 ] [ ID #1860552 ]

Re: Changing mtime of a symlink

Robert Latest wrote:
>
> How can the modification time of a symlink be set to an
> arbitrary date?

Recreate you symlink with

ln -sf target link_name

--
Best regards | Be nice to America or they'll bring democracy to
Cyrus | your country.
Cyrus Kriticos [ Fr, 02 November 2007 12:28 ] [ ID #1860554 ]

Re: Changing mtime of a symlink

On Nov 2, 4:28 pm, Cyrus Kriticos <cyrus.kriti... [at] googlemail.com>
wrote:
> Robert Latest wrote:
>
> > How can the modification time of a symlink be set to an
> > arbitrary date?
>
> Recreate you symlink with
>
> ln -sf target link_name
>
> --
> Best regards | Be nice to America or they'll bring democracy to
> Cyrus | your country.

Yeah recreating the symlink is a better option, but again changing the
modification time to an arbitary
date doesn't seem to be possible ?
ramesh.thangamani [ Fr, 02 November 2007 12:40 ] [ ID #1860556 ]

Re: Changing mtime of a symlink

Cyrus Kriticos wrote:

> Recreate you symlink with
>
> ln -sf target link_name

Yeah, but then it has today's date and not the one I want (namely, the date
of the linked file).

robert
Robert Latest [ Fr, 02 November 2007 13:41 ] [ ID #1860562 ]

Re: Changing mtime of a symlink

Robert Latest wrote:
> Cyrus Kriticos wrote:
>
>> Recreate you symlink with
>>
>> ln -sf target link_name
>
> Yeah, but then it has today's date and not the one I want (namely, the date
> of the linked file).

Right, my mistake.

What about recreating all links as hard links?

--
Best regards | Be nice to America or they'll bring democracy to
Cyrus | your country.
Cyrus Kriticos [ Fr, 02 November 2007 17:06 ] [ ID #1860566 ]

Re: Changing mtime of a symlink

Cyrus Kriticos wrote:

> What about recreating all links as hard links?

Nothing wrong with hard links. Except I don't really like 'em. Ho hum, I
just might do that.

robert
Robert Latest [ Fr, 02 November 2007 17:11 ] [ ID #1860567 ]
Linux » comp.unix.shell » Changing mtime of a symlink

Vorheriges Thema: Expect, How do I have different output for different prompts
Nächstes Thema: sed insert text on newline after pattern