From a63a8817812db37857ed3ad310f9277d70d3bac5 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 23 Nov 2021 16:49:03 +0800 Subject: [PATCH] up --- plugins/clean/index.html | 2 +- plugins/clean/index.py | 26 ++++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/plugins/clean/index.html b/plugins/clean/index.html index f860ac7b0..23cc972a7 100755 --- a/plugins/clean/index.html +++ b/plugins/clean/index.html @@ -16,7 +16,7 @@ pluginService('clean'); function pRead(){ var readme = ''; $('.soft-man-con').html(readme); diff --git a/plugins/clean/index.py b/plugins/clean/index.py index f367a845a..136791968 100755 --- a/plugins/clean/index.py +++ b/plugins/clean/index.py @@ -89,6 +89,20 @@ def get_filePath_fileName_fileExt(filename): return filepath, shotname, extension +def cleanFileLog(path): + filepath, shotname, extension = get_filePath_fileName_fileExt(abspath) + if extension == ".log": + cmd = "echo \"\" >> " + abspath + print(cmd) + mw.execShell(cmd) + + +def cleanDirLog(path): + l = os.listdir(path) + + print(l) + + def cleanLog(): # 清理日志 rootDir = "/var/log" @@ -100,6 +114,7 @@ def cleanLog(): "rm -rf /var/log/secure-*", "rm -rf /var/log/spooler-*", "rm -rf /var/log/yum.log-*", + "rm -rf /var/log/messages-*", "rm -rf /var/log/btmp-*", ] @@ -112,12 +127,11 @@ def cleanLog(): # print(l) for x in range(len(l)): abspath = rootDir + "/" + l[x] - filepath, shotname, extension = get_filePath_fileName_fileExt(abspath) - if extension == ".log": - cmd = "echo \"\" >> " + abspath - print(cmd) - print(mw.execShell(cmd)) - print(filepath, shotname, extension) + if os.path.isfile(abspath): + cleanFileLog(abspath) + + if os.path.isdir(abspath): + cleanDirLog(abspath) print("clean end")