Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

how to change last modification time of a symlink

Posted on 2001-09-09
6
560 Views
Last Modified: 2013-12-26
I need to change last modification time of a symlink. I tried with 'utime' library call, but it follows symbolic link and change the inode.st_mtime field of the file the link is referring to.

Is there another call to change that field to the symlink itself?
If not, does anybody known a trick to do it?

I also read 'touch' man page. It does not have such a functionality.

thank you for your support.
0
Comment
Question by:mliberi
6 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6468913
touch can do it, but only as user root (not shure for links, this probably also depends on the underlaying shell)
0
 
LVL 14

Expert Comment

by:chris_calabrese
ID: 6470598
touch sits on top of utime, so if utime can't do it, then touch can't do it either.

What exactly is the problem you're trying to solve?  utime follows links because the folks who did links couldn't imagine a situation where anyone would care what the modification time of a link was.

The only way I know of to change the mod time of a link is to delete the link and recreate it.
0
 
LVL 3

Author Comment

by:mliberi
ID: 6470841
I'm trying to restore a saved symlink. I use lchown to restore uid and gid and I would expect a system call or C library call exist to set last modification time too.

Removing and recreating the link is not a solution because it sets current time, not a generic timestamp. Change current time for the time necessary to do that operation is not an accepted solution.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 14

Accepted Solution

by:
chris_calabrese earned 100 total points
ID: 6472176
Like I said, the creators of the sym-link stuff assumed that mod times for a link aren't important, so there's no way to do this.  You'd need an lutime or an futime, which don't exist.
0
 
LVL 20

Expert Comment

by:tfewster
ID: 8191635
No comment has been added lately, so it's time to clean up this Topic Area.
I will leave a recommendation for this question in the Cleanup topic area as follows:

- Answered by chris_calabrese

Please leave any comments here within the next 7 days

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

tfewster
Cleanup Volunteer
0
 

Expert Comment

by:modulo
ID: 8241253
Finalized as proposed

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 49
Detect CR LF to each line 12 169
haveThree challenge 22 121
Execute multiple curl cmds with sleep and send output to file 10 104
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question