惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
Know Your Adversary
Know Your Adversary
P
Palo Alto Networks Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
K
Kaspersky official blog
L
LINUX DO - 热门话题
P
Proofpoint News Feed
P
Privacy & Cybersecurity Law Blog
Google DeepMind News
Google DeepMind News
Attack and Defense Labs
Attack and Defense Labs
Cisco Talos Blog
Cisco Talos Blog
AI
AI
L
LINUX DO - 最新话题
H
Heimdal Security Blog
Hacker News: Ask HN
Hacker News: Ask HN
Webroot Blog
Webroot Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The GitHub Blog
The GitHub Blog
I
Intezer
Blog — PlanetScale
Blog — PlanetScale
有赞技术团队
有赞技术团队
S
Securelist
博客园_首页
IT之家
IT之家
Schneier on Security
Schneier on Security
博客园 - 叶小钗
罗磊的独立博客
WordPress大学
WordPress大学
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
阮一峰的网络日志
阮一峰的网络日志
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
W
WeLiveSecurity
The Register - Security
The Register - Security
D
DataBreaches.Net
S
Security @ Cisco Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
腾讯CDC
Recorded Future
Recorded Future
NISL@THU
NISL@THU
N
News and Events Feed by Topic
T
Tailwind CSS Blog
N
News and Events Feed by Topic
Cyberwarzone
Cyberwarzone
T
Tor Project blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com

博客园 - 会走路的虾米

springboot怎样动态加载配置文件 windows下3主3从的redis5.X集群 html5图片实现双指拉大 windows上的TortoiseSVN迁移到另一台windows上 查看linux内存使用情况的相关命令 pom.xml文件中xmlns作用 linux下安装jdk java中String的3个替换方法(replace,replaceAll,replaceFirst)的区别 把tomcat做成服务模式 解决unable to find valid certification path to requested target windows校验下载文件的md5 冒泡排序法的写法 eclipse中使用maven创建springmvc项目 eclipse中创建简单maven项目,并导出jar包运行 eclipse创建maven模块化web项目 js获取iframe最上层或者上上层的元素值 slf4j下使用log4j myeclipse使用tortoisesvn sl4j日志加traceId
定时任务清除Windows服务器30天以上java系统日志
会走路的虾米 · 2025-10-15 · via 博客园 - 会走路的虾米

最近服务器上的java系统运行着的时候,突然挂掉了,后来查询问题发现是系统日志太多,把硬盘空间占满了。

于是就上网查询了关于定时任务清除30天以上的系统日志,特意整理成文章,方便自己和别人查询。

第一步,创建cleanLogs.bat文件(名称可自定义),内容如下:

@echo off
:: 设置日志目录路径(根据实际路径修改)
set "LogDir=C:\java_log\system"
:: 删除30天前的系统日志(*代表所有30天前的文件,可以按自己需求,修改为*.log)
forfiles /p "%LogDir%" /s /m * /d -30 /c "cmd /c del /f /q @path" 
echo 日志清理完成:%date% %time%
pause

第二步,打开任务计划程序

Win + R,输入taskschd.msc回车。

或通过“控制面板 > 管理工具 > 任务计划程序”。

第三步,创建基本任务

右侧点击“创建基本任务”,输入名称(如“定时清理系统日志”)。

选择触发器(如“每日”),设置执行时间(如凌晨3点)。

选择“启动程序”,浏览并选择cleanLogs.bat文件。

点击“完成”保存任务。