将进程内存大小报告给 Excel 文件的脚本
是否可以编写一个脚本,每天在特定时间执行并检查一个进程占用的内存大小并将结果写入 Excel 文件?该 Excel 文件应每天更新,并且不应删除旧记录。操作系统是Windows Server 2003。
我真的对脚本一无所知,我将感谢所有帮助我写这篇文章的人。谢谢。
Is it possible to write a script that will execute every day in certain time and check size of memory that one process is taking and write that result to an Excel file? That Excel file should be updated every day and old record shouldn't be deleted. OS is Windows Server 2003.
I really don't know anything about scripts and I would be grateful to all of you who help me write this. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您可以使用 CSV 格式(Excel 将打开它)而不是 XLS,则可以轻松使用
tasklist
命令来实现此目的。创建包含以下代码的 .bat 文件:
将
cmd.exe
更改为您要跟踪的进程,将c:\report.csv
更改为您要使用的文件名供您报告。您可以使用 Windows 计划任务将其设置为每天运行。
编辑:关于您的评论,我假设您指的是当前日期和时间?我不确定为什么你会跳过行 - 我的机器上没有得到这个。
这是一个稍微复杂的脚本,它将当前日期和时间添加到每行的开头:
If you are ok with using CSV format (Excel will open it) instead of XLS, you can easily use the
tasklist
command for this.Make a .bat file containing this code:
Change
cmd.exe
to the process that you want to track, andc:\report.csv
to the filename you want to use for your report.You can use Windows scheduled tasks to set it to run every day.
Edit: Regarding your comment, I'm assuming you mean current date and time? I'm not sure why you would be getting skipped rows - I don't get that on my machine.
Here's a slightly more complicated script that adds the current date and time to the start of each row: