1

Over time, a once tidy directory structure is changed and extended in unanticipated ways on a needs bases. After enough years go by it becomes 'a mess'.
Of course, I had nothing to do with it. :-)

Now everyone is afraid to touch it, because a multitude of applications rely on the existing filenames.

For easier maintenance and navigation, and better peace of mind, I'm now moving and renaming quite a few of our files and folders with a new sense of organization. I will of course have to update many applications as part of this process.

Since this takes some time, I have to create a symbolic links for the old filename, to point programs to the new location for compatibility. This is temporary until my updates rare completed.

But how can I be sure I haven't missed anything? I think the best thing is to use the 'last accessed' time of the symbolic link. If there are no accesses for over a year, then there are clearly no mission-critical applications relying on the old filenames.

I normally can check access times using ls -lhtue. Unfortunately, the l option queries the symbolic link to see where it leads, and then updates the access time of the symbolic link.

What command can I use to query the access time without actually updating it?

  • ls -opts /dev/fd/3 3<link – mikeserv Jan 7 '16 at 23:26
1

You may use the stat command:

  $stat -c --%x file or symlink

It doesn’t change it , it just report the last access time

  man stat
  NAME
   stat - display file or file system status

  SYNOPSIS
   stat [OPTION]... FILE...

  .............................
  .............................
   %w     time of file birth, human-readable; - if unknown

   %W     time of file birth, seconds since Epoch; 0 if unknown

   %x     time of last access, human-readable

   %X     time of last access, seconds since Epoch

   %y     time of last modification, human-readable

   %Y     time of last modification, seconds since Epoch

   %z     time of last change, human-readable

   %Z     time of last change, seconds since Epoch
   ...............................................
   ...............................................
  • This assumes neither relatime nor noatime are set, which isn't the common case anymore. – Bratchley Jan 7 '16 at 23:28
  • @Bratchley, With relatime, "the atime will only updated once a day". So actually this still solves the problem. If I had noatime enabled then I wouldn't be asking the question. Others reading this post should be aware of those two situations where atime may not behave as expected. – Bryan Field Jan 8 '16 at 19:12
  • "If I had noatime enabled then I wouldn't be asking the question." I don't get how that makes sense at all. Just because you don't update atime doesn't means you're uninterested in being notified of file accesses. It just means you don't want to update atime. For instance there's inotify which doesn't do that. There's also filesystem auditing via auditctl etc. I don't know if those work with symlinks though, hence I didn't post an answer. – Bratchley Jan 9 '16 at 2:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.