[Chapter 21] 21.5 What Good Is a File's Last Access Time?
Author: Jerry Peek, Tim O'Reilly & Mike Loukides
Date: 1998-08-04T21:40:04Z

#

| Chapter 21 More About Managing Files |

## 21.5 What Good Is a File's Last Access Time?

UNIX keeps three times for each file: last modification, last inode change, and last access. Here are some things you can do with the last-access time:

- Find files that have been forgotten. This information comes from commands like ls -lu (16.2) and find -atime +180 (17.5). (If you use the MH email system, you can find mail messages that haven't been read or scanned in a long time.) You can save disk space by cleaning up unused files; see article 23.19.

- Automatically gzip (24.7) files to save disk space. Some users run a shell script named compresser, which looks for nonexecutable files that haven't been accessed in 90 days. The program runs gzip on these files:

      -perm -100
      xargs
      find dir1 dir2 -type f ! -name '*.gz' ! -perm -100 -atime +90 -print | \
          xargs gzip -v

  A system like this could automatically archive files to tape and delete them. It could have a personal "skip" list of files and directories to skip. And so on...

- Check a directory to see which files are being read by programs, compilers, etc. This "sanity check" can help you debug programs by confirming which files are being accessed.

> NOTE: Some UNIX systems, including versions of BSD and SunOS, do not update the access time of executable files (programs) when they're executed. To test yours, use ls -lu on a pure-executable file (not a shell script) before and after you run it.

- JP

21.4 Why Both /tmp and /usr/tmp? |  | 21.6 A File's Inode Change (not "Creation"!) Time