Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Solaris Lst Accessed date via script

Status
Not open for further replies.

MrToots

MIS
Oct 31, 2001
1
US
From the File manager GUI, properties, I can see both the last modified date and last accessed date of a file.

I want to use the last accessed date in a script but a command such as 'ls -l' only lists the last modified date. How can I get to the last accessed date of a file?
 
You can use "truss" to get at,mt and ct.

#truss -vlstat -tlstat ls -l tfile
lstat64("tfile", 0xEFFFF380) = 0
d=0x0080000F i=194347 m=0100750 l=1 u=1004 g=1 z=5018
at = Feb 28 10:21:01 GMT 2002 [ 1014891661 ]
mt = Nov 29 19:35:10 GMT 2001 [ 1007062510 ]
ct = Feb 1 18:11:18 GMT 2002 [ 1012587078 ]
bsz=8192 blks=10 fs=ufs
-rwxr-x--- 1 tpm other 5018 Nov 29 19:35 tfile

In the Unix file system, files have a last-modified time (shown by "ls -l"), a last-accessed time (shown by "ls -lu") and an inode change time (shown by "ls -lc"), the latter is often referred to as the "creation time", even in some man pages but that's wrong, it's also set by such operations as mv, ln,chmod, chown and chgrp.
"mtime" - time the contents of file was last modified (written to).
"atime" - time the file was last used/accessed (read or executed)
"ctime" - time the inode of the file was last changed (like changing permissions), ctime also gets updated every time mtime is modified, but not when the atime is changed, in the other thread.

Hope it Helps,

Regards,

Carlos Almeida,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top