?
Solved

Linux access time efficiency question

Posted on 2013-01-05
8
Medium Priority
?
232 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 79

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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 79

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 79

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

I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month8 days, 12 hours left to enroll

764 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