Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Linux access time efficiency question

Posted on 2013-01-05
8
Medium Priority
?
237 Views
Last Modified: 2013-01-21
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
Comment
Question by:RegProctor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 9

Assisted Solution

by:gt2847c
gt2847c earned 668 total points
ID: 38747929
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
 
LVL 80

Expert Comment

by:arnold
ID: 38747991
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
 
LVL 11

Assisted Solution

by:Chris Sandrini
Chris Sandrini earned 1332 total points
ID: 38748084
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
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
LVL 80

Expert Comment

by:arnold
ID: 38748500
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
 
LVL 11

Accepted Solution

by:
Chris Sandrini earned 1332 total points
ID: 38748799
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
 
LVL 80

Expert Comment

by:arnold
ID: 38749118
misinterpreted the question.
0
 
LVL 1

Author Comment

by:RegProctor
ID: 38800783
I want to thank everyone. There is a lot of good information here.
0
 
LVL 1

Author Closing Comment

by:RegProctor
ID: 38800799
Terrific, thanks guys.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Fine Tune your automatic Updates for Ubuntu / Debian
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question