Files
juipnet/script/clearpsiplog.js
wanyongkang d318014316 初始提交
2020-10-07 20:25:03 +08:00

36 lines
768 B
JavaScript

#! /usr/bin/node
const fs = require('fs');
const dayjs = require('dayjs');
const shell = require('shelljs');
const is_numeric = (value) => {
if (typeof (value) === 'object') {
return false;
} else {
return !Number.isNaN(Number(value));
}
};
const startPath = "/data/docker/applog/psip";
fs.readdirSync(startPath).forEach(item => {
fs.readdirSync(`${startPath}/${item}/Logs`).forEach(logDir => {
if (is_numeric(logDir)) {
var date = dayjs(logDir.toString());
if (date.isBefore(dayjs().subtract(7, 'day'))) {
const deleteDir = `${startPath}/${item}/Logs/${logDir}`;
shell.exec(`rm -rf ${deleteDir}`);
console.log(`删除文件夹${deleteDir}`);
}
}
})
});