1

I was trying to find the time of database backup. Normally i use

ls -ltch

But this time i used

ls -lrth

It gave me different result for One file and all date-stamps were same for both commands

-rw-r----- 1 oracle dba  41M Dec  7 23:59 ctrl_071223
-rw-r----- 1 oracle dba  42M Dec  7 20:52 c-4249173797-20121207-00
-rw-r----- 1 oracle dba 202M Dec  7 20:52 ALG_OSLPRD_jens9rfr.alg
-rw-r----- 1 oracle dba 189M Dec  7 20:52 ALG_OSLPRD_jfns9rfr.alg
-rw-r----- 1 oracle dba 140M Dec  7 20:52 ALG_OSLPRD_jgns9rfr.alg
-rw-r----- 1 oracle dba 3.0G Dec  7 20:51 BKPOSLPRD_jbns9p1f.F_bkp
-rw-r----- 1 oracle dba 4.2G Dec  7 20:46 BKPOSLPRD_jdns9p1f.F_bkp
-rw-r----- 1 oracle dba 3.8G Dec  7 20:43 BKPOSLPRD_jcns9p1f.F_bkp
[root@pdbosl02 daily]# ls -lrth
total 12G
-rw-r----- 1 oracle dba 3.8G Dec  7 20:43 BKPOSLPRD_jcns9p1f.F_bkp
-rw-r----- 1 oracle dba 4.2G Dec  7 20:46 BKPOSLPRD_jdns9p1f.F_bkp
-rw-r----- 1 oracle dba 3.0G Dec  7 20:51 BKPOSLPRD_jbns9p1f.F_bkp
-rw-r----- 1 oracle dba 140M Dec  7 20:52 ALG_OSLPRD_jgns9rfr.alg
-rw-r----- 1 oracle dba 189M Dec  7 20:52 ALG_OSLPRD_jfns9rfr.alg
-rw-r----- 1 oracle dba 202M Dec  7 20:52 ALG_OSLPRD_jens9rfr.alg
-rw-r----- 1 oracle dba  42M Dec  7 20:52 c-4249173797-20121207-00
-rw-r----- 1 oracle dba  41M Dec  7 20:52 ctrl_071223

What I'm missing

1 Answer 1

3

The differences between both commands are:

  • the 2nd listing is sorted in reverse (-r)
  • the 2nd listing uses the modification time stamp as sort key (-t)
  • the 1st listing uses the ctime stamp as sort key (-tc)

On UNIX a file has 3 time stamps (atime, ctime, mtime) which are updated under different conditions.

To quote the wikipedia article on stat:

atime: time of last access (ls -lu), mtime: time of last modification (ls -l), and ctime: time of last status change (ls -lc).

An example for a status change is changing the permissions of a file.

3
  • Partially understood. But one thing is bothering me the timestamp of First line of First Listing and the Last Line of 2nd Listing is different and all other entries and same time in both listing. And I updated the Question Synchronized the commands based on Output. 2nd listing dont have the -tc flag
    – OmiPenguin
    Dec 8, 2012 at 14:33
  • @UmairMustafa, updated the answer. Well, some event happened that triggered the ctime update. And that event only happened on ctrl_071223 (I gave an example of such an event in the answer and referenced the section in the Wikipedia article that discusses the semantics of the ctime stamp). Dec 8, 2012 at 14:39
  • Ahh now i understand thanks dear for great explanation.
    – OmiPenguin
    Dec 8, 2012 at 14:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .