Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Unsure why access time on a directory change isn't changing Post 303037890 by hicksd8 on Thursday 15th of August 2019 05:12:14 PM
Old 08-15-2019
You didn't say which operating system this is but there has to be difference between read and open. If you think about it, if a read updated the access time then all the access times would change when a backup is run which wouldn't be any good if you had to restore the whole lot. However, if an application opens a file then that will update the access time. For example, if you open a file with vi and then immediately quit with :q!, the access time should update because the file has been specifically opened. Additionally, if youvi followed by :w! (even if you haven't changed anything) the file will be written back so the modified date should change.

Now with a directory it is holding the details of its files so if a new file is created the directory is modified. Also, if an application specifically opens a file with that directory in its pathname (and blocks may need to be allocated/deallocated to the file), then the access time should change.

You should be able to verify this on your operating system with a few tests.

Last edited by hicksd8; 08-16-2019 at 05:20 AM..
These 2 Users Gave Thanks to hicksd8 For This Post:
 

8 More Discussions You Might Find Interesting

1. Solaris

help in changing the access level for directories

Hi all, can some one help me in chmod command, and let me know the various combinations for this command. for : eg chmod -R 777 <dir names> this gives all rights to all but i want the specific access levels kindly help me out in this issue. Thank you, lakshmanan (2 Replies)
Discussion started by: lakshmananl
2 Replies

2. Linux

A little unsure of something

If i want to display a banner that says Happy Bday, but I want to put that output banner into a file called bday4me, could I use the command (echo) or (banner -w35) Happy Bday >> bday4me would this command work? Sorry for asking, but i'm at home just now and don't have access to a UNIX... (3 Replies)
Discussion started by: Cisco
3 Replies

3. Shell Programming and Scripting

How to change prompt color when changing path

Hi all, Can you tell me how to change the prompt color (only the path part) when I chnange directory with "cd"? I use the sequence below in ".bashrc" (Solaris 8) to change my prompt colors and I'd like to modify it to change the path color when I cange directory. PSC() { echo -ne "\"; }... (0 Replies)
Discussion started by: majormark
0 Replies

4. Shell Programming and Scripting

Last modified time of the folder is changing when I view the file inside the directory

Hi., Last modified time of the folder is changing when I view the file inside the directory. Here is the test on sample directory. I believe that ls -l commands gives the time detail w.r.t last modified time. Pl. suggest. bash-3.2$ mkdir test bash-3.2$ cd test bash-3.2$ touch myfile.txt... (2 Replies)
Discussion started by: IND123
2 Replies

5. UNIX for Dummies Questions & Answers

File access time does not change on some files

Hey All, I want to get the access time of files in a directory. I used ls -lu on a directory and picked a file that had the access time of Mar 1 and used cat to get the contents of the file. Then I used the ls -lu again and the access time changed on that file. Perfect !! Now if I cat a... (10 Replies)
Discussion started by: vipulgupta0
10 Replies

6. Shell Programming and Scripting

Unsure of sed notation (nu\\t.\*)

This piece of code is in a shell script I'm trying to modify to run on my system. sed s:nu\\t.\*:"nu=0" It's clearly a substitute script which replaces nu\\t.\* with nu = 0. What exactly does nu\\t.\* demarcate though-- I thought it was just the previous nu = xxxxx (which existed and is... (3 Replies)
Discussion started by: czar21
3 Replies

7. Shell Programming and Scripting

Change to directory and search some file in that directory in single command

I am trying to do the following task : export ENV=aaa export ENV_PATH=$(cd /apps | ls | grep $ENV) However, it's not working. What's the way to change to directory and search some file in that directory in single command Please help. (2 Replies)
Discussion started by: saurau
2 Replies

8. Shell Programming and Scripting

Bash looking in different directory for file that isn't referenced in command

When I run the below bash I get the expected output, which is the sum of all matching targets less than 20 in $file1. The filename in the directory is fixed (in bold). for file1 in /home/cmccabe/Desktop/test/panel/reads/16-0000_EPIL70.txt ; do bname=`basename $file1` ... (3 Replies)
Discussion started by: cmccabe
3 Replies
open(2) 							System Calls Manual							   open(2)

NAME
open() - open file for reading or writing SYNOPSIS
Remarks The ANSI C "" construct specifies a variable length argument list whose optional member is given in the associated comment DESCRIPTION
The system call opens a file descriptor for the named file and sets the file status flags according to the value of oflag. The path argument points to a path name naming a file, and must not exceed bytes in length. The oflag argument is a value that is the bitwise inclusive OR of flags listed in "Read-Write Flags," "General Flags," "Synchronized I/O Flags," and "Direct I/O Flags" below. The optional mode argument is only effective when the flag is specified. The file pointer used to mark the current position within the file is set to the beginning of the file. The new file descriptor is set to remain open across system calls. See fcntl(2). Read-Write Flags Exactly one of the or flags must be used in composing the value of oflag. If none or more than one is used, the behavior is undefined. Open for reading only. Open for writing only. Open for reading and writing. General Flags Several of the flags listed below can be changed with the system call while the file is open. See fcntl(2) and fcntl(5) for details. If set, the file offset is set to the end of the file prior to each write. If the file exists, this flag has no effect, except as noted under below. Otherwise, the owner ID of the file is set to the effective user ID of the process, the group ID of the file is set to the effective group ID of the process if the set-group-ID bit of the parent directory is not set, or to the group ID of the parent directory if the set-group-ID bit of the parent directory is set. The file access permission bits of the new file mode are set to the value of mode, modified as follows (see creat(2)): o For each bit set in the file mode creation mask of the process, the corresponding bit in the new file mode is cleared (see umask(2)). o The "save text image after execution" bit of the new file mode is cleared. See chmod(2). o On HFS file systems with access control lists, three base ACL entries are created corresponding to the file access permissions (see acl(5)). o On JFS file systems that support access control lists, optional ACL entries are created corresponding to the par- ent directory's default ACL entries (see aclv(5)). If and are set and the file exists, fails. This is a non-standard flag which may be used by 32-bit applications to access files larger than 2 GB. See creat64(2). This flag might affect subsequent reads and writes. See read(2) and write(2). When opening a FIFO with or set: If is set: A read-only returns without delay. A write-only returns an error if no process currently has the file open for reading. If is clear: A read-only does not return until a process opens the file for writing. A write-only does not return until a process opens the file for reading. When opening a file associated with a communication line: If is set: The returns without waiting for carrier. If is clear: The does not return until carrier is present. If set, and path identifies a terminal device, does not cause the terminal to become the controlling terminal for the process. If the last component of path refers to a symbolic link, the will fail. This is true regardless of whether the target of the link exists or not. NOTE: If the symbolic link in path is followed by a trailing '/', the link will be traversed, regardless of the set- ting of Same effect as for open(2), but slightly different effect in read(2) and write(2). If both and are specified, takes precedence. If the file exists, its length is truncated to 0 and the mode and owner are unchanged. Synchronized I/O Flags Together, the and flags constitute support for Synchronized I/O. These flags are ignored for files other than ordinary files and block special files on those systems that permit I/O to block special devices (see pathconf(2)). If both the and flags are set, the effect is as if only the flag was set. The flag is ignored if it is not set along with the or flag. If a file is opened with or that flag is set with the option of writes to that file by the process block until the data specified in the write request and all file attributes required to retrieve the data are written to the disk. File attributes that are not necessary for data retrieval (access time, modification time, status change time) are not necessarily written to the disk prior to return- ing to the calling process. Identical to with the addition that all file attributes changed by the write operation (including access time, modification time, and sta- tus change time) are also written to the disk prior to returning to the calling process. Identical to for file system writes. For file system reads, the calling process blocks until the data being read and all file attributes required to retrieve the data are the same as their image on disk. Writes pending on the data to be read are executed prior to returning to the call- ing process. Identical to for file system writes. Identical to for file system reads, with the addition that all file attributes changed by the read operation (including access time, modification time, and status change time) too are the same as their image on disk. RETURN VALUE
returns the following values: Successful completion. n is a file descriptor for the opened file. Failure. is set to indicate the error. ERRORS
If fails, is set to one of the following values. [EACCES] oflag permission is denied for the named file. [EACCES] A component of the path prefix denies search permission. [EACCES] The file does not exist and the directory in which the file is to be created does not permit writing. [EACCES] is specified and write permission is denied. [EAGAIN] The file exists, enforcement mode file/record locking is set (see chmod(2)), there are outstanding record locks on the file with the or system calls, and is set. [EDQUOT] User's disk quota block or inode limit has been reached for this file system. [EEXIST] and are set and the named file exists. [EFAULT] path points outside the allocated address space of the process. [EINTR] A signal was caught during the system call, and the system call was not restarted (see signal(5)). [EINVAL] oflag specifies both and [EISDIR] The named file is a directory and oflag is write or read/write. [ELOOP] Too many symbolic links are encountered in translating the path name. [EMFILE] The maximum number of file descriptors allowed are currently open. [ENAMETOOLONG] The length of the specified path name exceeds bytes, or the length of a component of the path name exceeds bytes while is in effect. [ENFILE] The system file table is full. [ENODEV] The named file is a character special or block special file, and the driver associated with this special file has not been configured into the kernel or the DLKM driver associated with this special file failed to load. [ENOENT] The named file does not exist (for example, path is null or a component of path does not exist, or the file itself does not exist and is not set). [ENOTDIR] A component of the path prefix is not a directory. [ENOTSUP] The last component of path is a sybolic link and was set. [ENXIO] is set, the named file is a FIFO, is set, and no process has the file open for reading. [ENXIO] The named file is a character special or block special file, and the device associated with this special file does not exist. [ENOSPC] is specified, the file does not already exist, and the directory that would contain the file cannot be extended. [EOVERFLOW] The named file is a regular file and the size of the file cannot be represented correctly in an object of size [EROFS] The named file resides on a read-only file system and oflag is write or read/write. [ETXTBSY] The file is open for execution and oflag is write or read/write. Normal executable files are only open for a short time when they start execution. Other executable file types can be kept open for a long time, or indefinitely under some circumstances. EXAMPLES
The following call to opens file for reading only and returns a file descriptor for For an example of reading from file see the read(2) manual entry. The following call to opens file for writing and returns a file descriptor for For an example of preallocating disk space for see the pre- alloc(2) manual entry. For an example of writing to see the write(2) manual entry. The following call opens file for synchronized I/O file integrity for reads and writes. AUTHOR
was developed by HP, AT&T, and the University of California, Berkeley. SEE ALSO
acl(2), chmod(2), close(2), creat(2), dup(2), fcntl(2), flock(2), lockf(2), lseek(2), creat64(2), pathconf(2), read(2), select(2), umask(2), write(2), setacl(2), acl(5), aclv(5), fcntl(5), privileges(5), signal(5), thread_safety(5), unistd(5). STANDARDS CONFORMANCE
open(2)
All times are GMT -4. The time now is 11:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy