//清除日志,只保留7日日志
function unlinklog()
{
var path = './Log'
setInterval(()=>{
fs.exists(path,(s)=>{
if(s){
let files = fs.readdirSync(path) //获取文件夹内容
if(files.length > 7){
//遍历文件夹内容
files.forEach(function(file) {
let stat = fs.statSync(path+'/'+ file)
let logtime = Math.round(stat.mtimeMs)
let times = (Math.round(new Date() / 1000) - (3600*24*10))*1000
if(logtime < times ){
fs.unlinkSync(path+'/'+file)
}
})
}else{
logWrite(path+"日志文件夹内容总数:"+files.length)
}
}
})
},1000*60*60)
}