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
Need help please with creating new Script to remove old .log files
Re: Need help please with creating new Script to remove old .log files
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.
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
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.