Operating System - HP-UX
1753431 Members
4701 Online
108793 Solutions
New Discussion юеВ

Re: Last access time of doc

 
Hakki Aydin Ucar
Honored Contributor

Last access time of doc

I wonder if I need to write a script to find last accessed time for some documents , OR there is a facility in HP-UX I do not know ?

Currently I am checking with find command like this; for example that files that havenтАЩt been accessed for at least 50 days

find /mydocs/onlinemanuals -name "*.pdf" -atime +50
10 REPLIES 10
Matti_Kurkela
Honored Contributor

Re: Last access time of doc

Times of last access can be displayed with the -u option of the ls/ll commands:

ll -u

MK
MK
Hakki Aydin Ucar
Honored Contributor

Re: Last access time of doc

I ve to be more specific ,in short; need a check some sort of docs. if they are in use frequently OR they are dormant?
of course some statistics as how frequently are they using will be better.
Hein van den Heuvel
Honored Contributor

Re: Last access time of doc


The file system only keeps one access times, the last one. And it has no access count.

If you need more, then you may have to roll your own, perhaps using a file to remember the last access time (in seconds) and count for a list of interesting files and process any file which was found accessed since the last run of that script.

All the information the file system keeps is available through the STAT function.

For example in PERL you could get the last access times for entries in a list of files in seconds since 1/1/1970 and then print as formatted string using:

perl -lpe 'chomp; $_=localtime((stat)[8])'

Full documentation:

http://perldoc.perl.org/functions/stat.html


fwiw,
Hein.
Hakki Aydin Ucar
Honored Contributor

Re: Last access time of doc

I am not good in Perl, with this in mind I am looking for a shell script solution. But it is good idea to learn some Perl maybe..
Which one is trust-able technically :

Unix find .. -atime OR
Perl stat ?
Michael Steele_2
Honored Contributor

Re: Last access time of doc

Hi

find / \( -name a.out -o -name '*.o' \) -atime +7

-atime n
True if the file access time subtracted from the initialized time is n-1 to n multiples of 24 h. The initialization time shall be a time between the invocation of the find utility and the first access by that invocation of the find utility to any file specified by its path operands. The access time of directories in pathname_list is changed by find itself.

-mtime n
True if the file modification time subtracted from the initialization time is n-1 to n multiples of 24 h. The initialization time shall be a time between the invocation of the find utility and the first access by that invocation of the find utility to any file specified in its path operands.

-ctime n
True if the time of last change of file status information subtracted from the initialization time is n-1 to n multiples of 24 h. The initialization time shall be a time between the invocation of the find utility and the first access by that invocation of the find utility to any file specified by its path operands.


http://docs.hp.com/en/B2355-90689/find.1.html
Support Fatherhood - Stop Family Law
Hakki Aydin Ucar
Honored Contributor

Re: Last access time of doc

when it comes to find's mtime atime ctime; I remember my confusing about period, and good explanation is for example mtime :

"-mtime -2" means files that are less than 2 days old, such as a file that is 0 or 1 days old.

"-mtime +2" means files that are more than 2 days old... {3, 4, 5, ...}

you can read more and wonderful post about this subject from :

http://www.unix.com/tips-tutorials/20526-mtime-ctime-atime.html

Just +10 points for this article :)
James R. Ferguson
Acclaimed Contributor

Re: Last access time of doc

Hi Hakki:

> Which one is trust-able technically : Unix find .. -atime OR Perl stat ?

They both yield the same result since they both use the underlying 'stat()' system call. See the manpages for 'stat(2)'.

Regards!

...JRF...
Michael Steele_2
Honored Contributor

Re: Last access time of doc

James:

May I say what a pleasure it is to read your responses. They always provide something out of the mainstream, often something I didn't know, they are always on target. And I don't see how you can answer some many questions and continue to maintain such a high standard of excellence.

Thank you, for the many years of your service to the forum.
Support Fatherhood - Stop Family Law
Dennis Handly
Acclaimed Contributor

Re: Last access time of doc

>you can read more and wonderful post about this subject from

This is probably more accurate than HP's man page.

>Michael: long quote from find(1)

The time measurement details are incorrect. What find(1) doesn't tell you is that is only valid if you are using:
UNIX95=FIDDLE_WITH_FIND_TIMES find ...
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1271016
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1331996
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1329090
http://forums13.itrc.hp.com/service/forums/questionanswer.do?admit=109447627+1255440037826+28353475&threadId=1329090