Operating System - HP-UX
1848584 Members
1897 Online
104033 Solutions
New Discussion

Re: changing modification time for a link

 
Hunki
Super Advisor

changing modification time for a link

I tried touch -mat MMDDhhmm link-name. But it does not work . I am a non -root user. How can I change the modification time for a link.

Thx !
7 REPLIES 7
Rajesh SB
Esteemed Contributor

Re: changing modification time for a link

Hi,

Even if you root user, time stamp wouldn't change for Symbolik link. If it is hardlink, you can change as owner.

Regards,
Rajesh
James R. Ferguson
Acclaimed Contributor

Re: changing modification time for a link

Hi:

There really is no need to worry about the modification timestamp ('mtime') nor permissions nor ownership of a symbolic link. It's the file or directory to which the link points that is generally followed and is of interest.

If you "must" alter the modification timestamp ('mtime') of a symbolic link, the easist way is to remove the link and recreate it. The entity pointed to by the link will not be removed, so the operation is safe.

Regards!

...JRF...
Hunki
Super Advisor

Re: changing modification time for a link

Can you give the steps on how to change it. I want to create a soft link which timestamp of Jan 2006.

Thx
James R. Ferguson
Acclaimed Contributor

Re: changing modification time for a link

Hi (again) Hunki:

Perhaps I misled you. If you remove a symbolic and recreate it, the 'mtime' of the link will be the current date/time. That's about the only alteration in the timestamp that you can make. Again, a symbolic link's permissions, ownership and timestamps are essentially meaningless, since links are followed to the entity to which the link points. It's the permisssions and ownership of the referenced link that counts.

Regards!

...JRF...
Hunki
Super Advisor

Re: changing modification time for a link

Thx
spex
Honored Contributor

Re: changing modification time for a link

Hunki,

There's really no good way to do this. You could temporarily change your system date, create the symlink, and then restore the date, but that's ugly. Or you could modify the inode of the symlink at the disk level, but that's also ugly. Both options are potentially dangerous.

PCS
A. Clay Stephenson
Acclaimed Contributor

Re: changing modification time for a link

A few flavors of UNIX implement the lutimes() system call to do to symbolic links what utimes() does to regular files. If the system call is present in HP-UX (which I rather doubt), it is undocumented.
If it ain't broke, I can fix that.