Hi all,
I have a simple question as it appears.
But am unable to get the solution.
Question is -how do I get the access time of a file in unix. please advise on the command.
Thanks
Hi all,
I have a simple question as it appears.
But am unable to get the solution.
Question is -how do I get the access time of a file in unix. please advise on the command.
Thanks
asked how to get a file's access time. Access time (atime) is the timestamp that records the last time file contents were read; in POSIX APIs it is the st_atime field returned by stat. It is different from modification time (mtime) and inode change time (ctime), so be sure you mean the read/last-access timestamp rather than a write or metadata-change timestamp. See the POSIX stat description for the formal fields and meanings (POSIX stat).
and gave useful starting points (check your utilities and the stat-style tools), but behavior varies by OS and filesystem. Many systems use mount options that avoid updating atime on every read for performance (for example, "noatime" or relaxed atime modes). Network filesystems, kernel caching, or programs opening files with flags that suppress atime updates can also make it look like atime never changes. The mount manual documents these options and their effects (mount(8) options).
A practical check: first inspect the mount options for the filesystem that holds the file, then read the file and compare its access-time field before and after. A portable way to print the access time is to use a small script; for example, this Python one-liner prints a human-readable atime:
python3 -c "import os,sys,time; st=os.stat(sys.argv[1]); print(time.ctime(st.st_atime))" path/to/file Run that once, read the file (for example with a simple tool that actually reads its contents), then run it again to see whether atime changed.
If atime does not change, check mount options and server-side settings (for NFS) or whether applications open files with flags that prevent atime updates (see open(2) for the O_NOATIME behavior). For reference on the Python fields used above see the Python os.stat docs (os.stat_result.st_atime).
Jump to Post— masijade 1,351man ls
man ls Masijade,
I already did it.
It didnt seem to work. So I created a thread for this.
Thanks
At least on Solaris "-u" is the option. For any other system you are going to have to man ls and actually read it to find out if any of the options have anything to do with access time and then actually try that option (and try it in combo with "-l", maybe).
Hi all,
I have a simple question as it appears.
But am unable to get the solution.Question is -how do I get the access time of a file in unix. please advise on the command.
Thanks
stat might give you what you want.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.