update the timestamp of symbolic links

I'm not sure if my private messages to cdoyle and rcarnesiii are being sent. So after searching for how to update the timestamp of symbolic links (NOT the file the link points) I decided to try here for better solutions. I understand that the FreeBSD's touch supports a -h option to update links' timestamps. Will building the BSD source code for "touch" work for Solaris? Where is a trust worthy url to get this source code?

Thanks!

I don't see how that could work. The touch program on FreeBSD has a lutimes() system call to implement that. I don't see a lutimes() in the Solaris documentation nor any evidence of it in /usr/include/sys/syscall.h.

A quick and dirty workaround if the target timestamp is "now". Run a shell script that removes the symbolic link then recreates it immediately. The risk a process would miss it during the small period of time it no more exists is probably low enough.

A better workaround would be to create a new symlink using an unpredictable temp name and then mv to clobber the old. POSIX requires the operation to be atomic so long as they're both part of the same filesystem (rename(2) syscall). Should the operation fail, the old link is unaffected. You'll always be guaranteed to have some version of the link present (serious I/O errors excepted, naturally).

Regards,
Alister

1 Like

Indeed, that's better.