Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 240
  • Last Modified:

Linux access time efficiency question

This is not a "how to", I just want to understand something.

As we know Linux is a very efficient system. However this concept of access time has me a little confused.

For example, if I did a find through the whole OS would it update the access time on every file? It just seems that would be incredibly inefficient with umteen file system writes to update a time stored on the hard disk for every file found.

If not does it get updated with an "fopen" statement or something else.

In other words, can someone tell me exactly what constitutes the access time getting updated?

Thanks... just furthering my in depth knowledge of Linux.
0
RegProctor
Asked:
RegProctor
  • 3
  • 2
  • 2
  • +1
3 Solutions
 
gt2847cCommented:
Access time is file opened for reading
Modified time is changes to file content

So unless the kernel executes the system call open(), the access time won't change.  Find is reading directory entries, and not opening the file (unless you are using the -exec function/option to perform something like grep on the current file)
0
 
arnoldCommented:
if you see a data file such as binary file where you do not want access time updated since it has no value, you can mount the partition with the noatime option.
The noatime option is usually used on partitions where binary database files are stored.
0
 
Chris SandriniSenior System EngineerCommented:
Hi

Checkout the answer I have written here
http://www.experts-exchange.com/OS/Unix/Q_27821074.html

For example, if I did a find through the whole OS would it update the access time on every file? It just seems that would be incredibly inefficient with umteen file system writes to update a time stored on the hard disk for every file found.

Open in new window


The access times of the files will not change as they will not be read. But the access time of the folder where the file is in will change. See this example

Create a file and get stat information
root@solidamber-kernel-x64:~# touch /tmp/file

root@solidamber-kernel-x64:~# stat /tmp/file
  File: `/tmp/file'
  Size: 0         	Blocks: 0          IO Block: 4096   regular empty file
Device: fe01h/65025d	Inode: 1010095     Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2013-01-06 07:29:33.000000000 +0100
Modify: 2013-01-06 07:29:33.000000000 +0100
Change: 2013-01-06 07:29:33.000000000 +0100

root@solidamber-kernel-x64:~# stat /tmp
  File: `/tmp'
  Size: 4096      	Blocks: 8          IO Block: 4096   directory
Device: fe01h/65025d	Inode: 1085281     Links: 11
Access: (1777/drwxrwxrwt)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2013-01-05 21:31:40.000000000 +0100
Modify: 2013-01-06 07:29:33.000000000 +0100
Change: 2013-01-06 07:29:33.000000000 +0100

Open in new window


Seach for the created file and read information

root@solidamber-kernel-x64:~# find /tmp -name file
/tmp/file

root@solidamber-kernel-x64:~# stat /tmp/file
  File: `/tmp/file'
  Size: 0         	Blocks: 0          IO Block: 4096   regular empty file
Device: fe01h/65025d	Inode: 1010095     Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2013-01-06 07:29:33.000000000 +0100
Modify: 2013-01-06 07:29:33.000000000 +0100
Change: 2013-01-06 07:29:33.000000000 +0100

root@solidamber-kernel-x64:~# stat /tmp/
  File: `/tmp/'
  Size: 4096      	Blocks: 8          IO Block: 4096   directory
Device: fe01h/65025d	Inode: 1085281     Links: 11
Access: (1777/drwxrwxrwt)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2013-01-06 07:29:49.000000000 +0100
Modify: 2013-01-06 07:29:33.000000000 +0100
Change: 2013-01-06 07:29:33.000000000 +0100 

Open in new window


As you can see. Only the access time of the folder has changed.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
arnoldCommented:
Access time is updated on every access to a resource.
This is the question the asker has is whether the update to the access time is an efficient use of resources even though the two times updates are the same in most systems. There is the create date that is set when the resource is created, access time that is updated on every access and the last is the modify date which is updated when data is written into the resources.

To access a file in any directory, the directory must be accessed.

The reason access time updates are useful is this information is needed if you need to decide whether a set of files in a share can be archived because they are not being used.  Without this data point, your data repository can not be trimmed without going to each person collecting information on which files each accesses and then archive any file that is not included in the collected information.
0
 
Chris SandriniSenior System EngineerCommented:
Arnold. The question was IF the access time of each found file would be updated if you do a find through the whole filesystem. The answer is NO. Find does not fopen all files that it is searching. The only access times that are updated, are the ones of the folders.

As long as you do not have any fopen syscalls it will not change your access time. Otherwise it will.
0
 
arnoldCommented:
misinterpreted the question.
0
 
RegProctorAuthor Commented:
I want to thank everyone. There is a lot of good information here.
0
 
RegProctorAuthor Commented:
Terrific, thanks guys.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now