last access time of a file

I was reading http://blogs.oracle.com/myoraclediary and there was a command about printing the modification details of a file.

In Linux / Cygwin “stat” exists as a command

$ stat /etc/hosts
Access: 2010-08-25 15:20:49.782522200 +0200
Modify: 2010-08-18 14:04:25.868114200 +0200
Change: 2010-08-18 14:04:26.072413100 +0200

Or use the one-liner perl below


### st_atime;         /* Time of last access */
$ perl -e 'use POSIX;[-f"/etc/hosts"]&&print ctime((stat(_))[8])'
Wed Aug 25 15:20:08 2010
### st_mtime;         /* Time of last data modification */
$ perl -e 'use POSIX;[-f"/etc/hosts"]&&print ctime((stat(_))[9])'
Wed Jun 10 11:36:40 2009
### st_ctime;         /* Time of last file status change */
$ perl -e 'use POSIX;[-f"/etc/hosts"]&&print ctime((stat(_))[10])' 
Wed Aug 25 01:00:07 2010

Published by

Laurent Schneider

Oracle Certified Master

5 thoughts on “last access time of a file”

  1. $ man ls

    –time=WORD
    with -l, show time as WORD instead of modification time: atime,
    access, use, ctime or status; use specified time as sort key if
    –sort=time

    example

    $ ls -l –time=atime hj.exe –full-time
    -rw-rw-r– 1 sokrates domainusers 2023424 2006-06-07 18:25:16.000000000 +0200 hj.exe
    $ ls -l –time=ctime hj.exe –full-time
    -rw-rw-r– 1 sokrates domainusers 2023424 2010-08-23 13:19:30.105623556 +0200 hj.exe

  2. ngt1> ls -ltr test_bal_mis_rech.sql
    -rw——- 1 oracle8 dba 3814 Jul 21 2011 test_bal_mis_rech.sql
    ngt1> ls -lu test_bal_mis_rech.sql
    -rw——- 1 oracle8 dba 3814 Aug 03 07:08 test_bal_mis_rech.sql

Leave a Reply

Your email address will not be published.


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>