Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^4: Analyzing Files Within a Directory

by afoken (Chancellor)
on Mar 21, 2017 at 05:08 UTC ( [id://1185305]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Analyzing Files Within a Directory
in thread Analyzing Files Within a Directory

that sounds like you need atime, access time.

Just a note: Updating atime may be "expensive" in some ways (e.g. the computer may need to spin up a laptop's harddisk just to update the atime of a file that is already in the buffer cache), so there are mount options to delay or completely prevent updating the atime. For linux, search for "noatime", "strictatime", "relatime" in the mount manpage for details.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
  • Comment on Re^4: Analyzing Files Within a Directory

Replies are listed 'Best First'.
Re^5: Analyzing Files Within a Directory
by afoken (Chancellor) on Mar 24, 2017 at 07:28 UTC

    A few more notes, after a msg by Marshall.

    noatime completely disables atime updates. This can be useful for files where atime is irrelevant, like everything in /bin, /sbin, /lib, /usr/bin, /usr/sbin, /usr/lib. No one cares when /bin/bash was read last. On a desktop / server, where disks rotate continuously, the atime update does not matter, but on a laptop or on flash media, like CF- (DIY firewall) or SD-cards (Raspi), each atime update means a disk update / a write cycle. So mounting those directories, or perhaps the entire root fs with noatime makes sense there. /home, /tmp and /var (or at least parts of /var) would live on a different filesystem with different mount options. If set up cleverly, the root fs could also be mounted read-only, preventing all updates including atime.

    strictatime is the classic unix behaviour. Update atime everytime a file is read.

    relatime is a clever hack. The atime is updated, but only if the previous atime was earlier than the current mtime or ctime. This helps programs like mutt to detect that a file has been read since the last modification. Newer Linux versions (>= 2.6.30) also update atime if the difference is larger than one day. Default since 2.6.30.

    Then, there is also lazytime. This updates atime, ctime, and mtime only in memory. For userspace, this should look like strictatime, but time changes require no disk access, so disks can be stopped, flash write cycles are prevented. Times are written to disk / flash only if something else changes in the inode, on fsync/syncfs/sync (e.g. from umount), when the (undeleted) inode is removed from memory, or more than 24 hours have been passed since the last write for the inode. Of course, if you need the atime/ctime/mtime in software, you don't want an unexpected power cycle or a crash, because all unwritten updates would be lost.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1185305]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-26 06:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found