0

My Goal is to find the files and delete them which are older than 1 day. I am using the command to find(list them) with find /trunk/logs/ -mtime +1 -name '*.log' -ls > $LogName or find /trunk/logs/ -mtime +1 -ls > $LogName. And to delete I am using find /trunk/logs/ -mtime +1 -exec rm -rfv {} \;. Unfornately I am not successful, here is from the server. can you suggest what I am missing ?

[trunk@Brave logs]$ find /trunk/logs/ -mtime +1  -name '*.log' -ls
[trunk@Brave logs]$ ls -lhtr
total 1.3M
-rw------- 1 trunk trunk  32K Jul 29 3:00 more.sh_2019-07-29.log
-rw------- 1 trunk trunk  27K Jul 29 3:00 Web.sh_2019-07-29.log
-rw------- 1 trunk trunk  85K Jul 29 3:00 Mount.sh_2019-07-29.log
-rw------- 1 trunk trunk  38K Jul 29 3:00 OOM.sh_2019-07-29.log
-rw------- 1 trunk trunk  21K Jul 29 3:00 lfy.sh_2019-07-29.log
-rw------- 1 trunk trunk  29K Jul 29 3:00 SUP.sh_2019-07-29.log
-rw------- 1 trunk trunk  64K Jul 30 4:00 Web.sh_2019-07-30.log
-rw------- 1 trunk trunk  75K Jul 30 4:00 more.sh_2019-07-30.log
-rw------- 1 trunk trunk  90K Jul 30 4:00 OOM.sh_2019-07-30.log
-rw------- 1 trunk trunk 203K Jul 30 4:00 Mount.sh_2019-07-30.log
-rw------- 1 trunk trunk  49K Jul 30 4:00 lfy.sh_2019-07-30.log
-rw------- 1 trunk trunk  67K Jul 30 4:00 SUP.sh_2019-07-30.log
-rw------- 1 trunk trunk  42K Jul 31 5:00 OOM.sh_2019-07-31.log
-rw------- 1 trunk trunk  35K Jul 31 5:00 more.sh_2019-07-31.log
-rw------- 1 trunk trunk  32K Jul 31 5:00 SUP.sh_2019-07-31.log
-rw------- 1 trunk trunk  95K Jul 31 5:00 Mount.sh_2019-07-31.log
-rw------- 1 trunk trunk  23K Jul 31 5:00 lfy.sh_2019-07-31.log
-rw------- 1 trunk trunk  30K Jul 31 5:00 Web.sh_2019-07-31.log
[trunk@Brave logs]$pwd
/trunk/logs/

Note : I have tried same with +2 as well , no luck. But If I remove -mtime +1 I am getting the whole list like any ls -ltr

Varja
  • 69
  • 1
  • 8
  • 1
    Possibly related: [Why does find -mtime +1 only return files older than 2 days?](https://unix.stackexchange.com/questions/92346/why-does-find-mtime-1-only-return-files-older-than-2-days) – steeldriver Jul 31 '19 at 18:37
  • Thank you , but that his/her question is about the behaviour of the command. For me, I am not getting the expected output with find command. – Varja Jul 31 '19 at 19:25
  • From the output and description the failure mode is unclear to me. In my timezone those all would be older than one day? How are you unsuccessful? – tink Jul 31 '19 at 20:05
  • @tink , thanks for response. That is the problem I am facing. I am not sure why its not working. – Varja Jul 31 '19 at 20:20
  • Again: I see no problem. In my TZ this looks like the desired output. – tink Jul 31 '19 at 20:31
  • I didn`t get it , are you also thinking like me why its not working or you are saying it should work and I am doing something wrong? – Varja Jul 31 '19 at 22:44

0 Answers0