Problem in file usage option

Hi,

I have a dout in -u option in ls command. If we give ls -lt command it will dispaly the last modfied time. If we give ls -lu command it will display the last usage time of the file.

My doubt here is Please refer the below commands.

/appldata/rsc/dm/RejectData$ls -lt ppi_amaz_dflt_disc_freq_dist_RejectData.bad
-rw-r-----   1 dqlet1   staff             0 Oct 15 13:11 ppi_amaz_dflt_disc_freq_dist_RejectData.bad
/appldata/rsc/dm/RejectData$ls -lu ppi_amaz_dflt_disc_freq_dist_RejectData.bad
-rw-r-----   1 dqlet1   staff             0 Sep 24 00:59 ppi_amaz_dflt_disc_freq_dist_RejectData.bad

In the above commnds in ls -lu command, i am getting the older date comparing with the timestamp in ls -lt command.

But ls -lu should show the newer timestamp right. Please correct me if i am wrong

Thanks,
Puni

Hi puni,

no ,it is not correct that the access time is newer than modified time,it depends upon the time you access.

ex

 cat >test1
this is test1 file

[biswa@dhcppc0 ~]$ cat test1
this is test1 file
[biswa@dhcppc0 ~]$ ls -lt test1
-rw-rw-r-- 1 biswa biswa 19 Oct 22 13:45 test1
[biswa@dhcppc0 ~]$ ls -lu test1
-rw-rw-r-- 1 biswa biswa 19 Oct 22 13:45 test1
[biswa@dhcppc0 ~]$ cat test1u
this is test1 file                                   ----------you accessed here so next access time is changed [biswa@dhcppc0 ~]$ ls -lu test1
-rw-rw-r-- 1 biswa biswa 19 Oct 22 13:46 test1
[biswa@dhcppc0 ~]$ ls -lt test1  -------------------but modified time unchanged
-rw-rw-r-- 1 biswa biswa 19 Oct 22 13:45 test1
[biswa@dhcppc0 ~]$ cat>>test1-----------now you appened means modified so the modtimechang
hello 
[biswa@dhcppc0 ~]$ ls -lt test1
-rw-rw-r-- 1 biswa biswa 25 Oct 22 13:47 test1
[biswa@dhcppc0 ~]$ ls -lu test1
-rw-rw-r-- 1 biswa biswa 25 Oct 22 13:46 test1

hope you will get it

Regards,
sanjay

Hi Sanjay,

Thank you. You are right . In your case usage time is the latest time.
But in my example usage time is older time.

What my doubt here is when the modified time is "Oct 15" how come the last usage time can be Sep 24?

Last usage time should be equal or newer than the modified time right?

Thanks,
Puni

see my last two lines of last post(-lu is 13:46 and -lt it 13:47)
and in your case it is clear no need to be baffled coz since sep 24 the file has not been accessed (it has not been opened ) and on oct 15 some modification is done so modi time is oct15.
I dont know how it confuses you.

Regards,
Sanjay.

Hi sanjay,

Thank you. Still i have confusion with the above point. If file got modified on oct 15 means, file sholud have accessed (i.e, opened) and then can able to modify the file right.

If so , in my point of view file usage time also should be oct 15 , is it correct? Please correct me if i am wrong

Thanks,
Puni

no you are wrong.

Please understand the following point carefully.

1:file can be modified without opening it. That is by cat >> filename here you are appending some text means , modifying it.(so it has no effect on access time).
2.if you are modifying with any editor like vi,vim or any.....and trying to modify some text inside it then you are first accessing it(vi filename) and then modifying it(when you are saving the changes).

hope this time you understood.

anytime welcome
Sanjay

1 Like

Thank you sanjay