Create delete logs timer

1. Create a file named deLog.sh.

2. Edit the text and enter the following:

#!/bin/bash

#tomcat log clearing script

function getPath()
{   wmsLogPath="/WMSlogs path"    ##wmsLogPath is the path corresponding to WMS, if there are more than one, you can modify the corresponding path after copying and pasting }


function delLog()
{   echo -e "\033[0;36mDelete the log files before 7 days...\033[0m"   find $wmsLogPath -name '*log*' -mtime +7 -exec rm -rf {} \;  ##find $wmsLogPath is to find the data under this path whose name contains log and whose time is seven days ago and delete it.  ##If there are more than one, you can modify the corresponding path after copying and pasting   echo -e "\033[0;36mDelete success...\033[0m" }





main()
{
  getPath
  delLog
}

main

Guess you like

Origin blog.csdn.net/Xin_shou__/article/details/128298882