Page 1 of 1

Need help please with creating new Script to remove old .log files

Posted: 2018/10/18 13:36:22
by hsalem935
Hello,

Can you please assist me on how to wrote this scripts to remover 2017 and older log files and just to keep 2018?

I have been doing this manually using .txt file

ls command will show:
-rw-rw-r-- 1 198661 Oct 16 09:01 cm-docsis-testsuite-IPv6.tcl-1539693695.log

in text file I modify entry to:
rm cm-docsis-testsuite-OSS.tcl-1501030190.log
but there are many files like that goes back to 2010

Thank for your help

Re: Need help please with creating new Script to remove old .log files

Posted: 2018/10/18 14:41:48
by tunk
Something like this should delete all log-files older than one year:
find . -maxdepth 1 -name "*.log" -mtime +365 -delete
I haven't actually tried it, so I would first test it on some dummy files, e.g. copy all log-files to another dummy directory.

Re: Need help please with creating new Script to remove old .log files

Posted: 2018/10/18 16:26:37
by hsalem935
Thank you very much for the quick response, I will sure try it and follow your advice and backup the file to a different Directory. :D