1. Write a shell script to clean up the log
#! /bin/bash
#进入要清理文件的路径
Cd/home/weblogic/bin
#echo "Please clear Startserver1.log and StartWebLogic.log"
#将文件内容清空
>startserver1.log
>startweblogic.log
Cd/home/weblogic/logs/tafs
#将文件内容清空
>send.log
#进入要清理文件的路径
Cd/home/weblogic/server1/logs
Number of files #统计当前目录下所有名称中含有 "Access.log0"
num1= ' Ls|grep access.log0|wc-w '
#判断num1是否大于0, the deletion is greater than 0
If [$num 1-gt 0];then
Files #删除所有文件名中含有 "Access.log0"
RM access.log0*
Fi
2. Place the shell script file anywhere on the Linux system and modify the file execution permissions: chmod +x file name
3, create a timed task: the current user of the Linux system (that is, the currently logged on user, and the user has proposed their own schedule crontab) execution: Crontab–e, and then edit in the Open file: */5 * * * *, Save and exit
4. Execute script: Go to the path where the script is located, execute./clearlog_135.sh
Scheduled cleanup of disk log steps under Linux