// 监听更新
function winUpdate(){
// 每次执行完后重新设置定时器
try {
// 获取当前时间并格式化为易读的字符串
const now = new Date();
const timeString = now.toLocaleString();
console.log(`当前时间: ${timeString}`);
// 记录内存使用情况(可选)
const memoryUsage = process.memoryUsage();
console.log(`内存使用: ${Math.round(memoryUsage.heapUsed / 1024 / 1024)} MB`);
console.log('定时任务执行中...');
}catch(error) {
console.error('定时任务出错:', error);
}finally {
// 无论如何都继续下一次执行
setTimeout(winUpdate, 1000);
}
}
winUpdate()
长期稳定运行