| 
 
weaishiqi 
初级用户
 
  
 
  
  
积分 24 
发帖 8 
注册 2006-7-22 
状态 离线
 | 
『楼 主』:
 [已结]每25分钟定时清空log.txt里面的所有内容
 
使用 LLM 解释/回答一下
  
新手求助: 希望大家能够解决小弟的问题 
 
小弟的D:\目录下有一个文本文件是log.txt 
 
log.txt文件会定时写入一些内容.小弟希望能够通过用批处理每25分钟清空log.txt里面的所有内容. 
 
也就是这个批处理是无限循环定时删除log.txt里面的所有内容的. 
 
请大家帮忙,为了这个文件小弟的头都大了,而且又不会批处理. 
 
恳求大家的帮忙~~~~~~~~~ 
 
 Last edited by willsort on 2006-7-22 at 19:29 ] 
Newbie seeking help: I hope everyone can solve my problem. 
 
There is a text file log.txt in my D:\ directory. 
 
The log.txt file will be written with some content regularly. I hope to use a batch script to clear all the content in log.txt every 25 minutes. 
 
That is, this batch script is an infinite loop to regularly delete all the content in log.txt. 
 
Please help me. For this file, my head is big, and I don't know batch scripting. 
 
Please help~~~~~~~~~ 
 
 Last edited by willsort on 2006-7-22 at 19:29 ] 
    
 
  
 |   
 | 
  2006-7-22 10:04 | 
  
 | 
 | 
 
skyearth 
初级用户
 
  
 
  
  
积分 34 
发帖 13 
注册 2006-7-20 
状态 离线
 | 
『第 2 楼』:
 
 
使用 LLM 解释/回答一下
  
看样子你得借助AT任务指令(或其他类似软件)定时执行批处理才能达到效果,不知你的系统中是否有此类命令 
It seems that you need to use AT task commands (or other similar software) to execute batch files regularly to achieve the effect. I wonder if there are such commands in your system 
    
 
  
 |   
 | 
  2006-7-22 10:42 | 
  
 | 
 | 
 
weaishiqi 
初级用户
 
  
 
  
  
积分 24 
发帖 8 
注册 2006-7-22 
状态 离线
 | 
『第 3 楼』:
 
 
使用 LLM 解释/回答一下
  
我不知道什么是AT任务指令~~~~~~~ 
I don't know what an AT task instruction is~~~~~~~ 
    
 
  
 |   
 | 
  2006-7-22 10:59 | 
  
 | 
 | 
 
namejm 
荣誉版主
 
        batch fan
  
 
积分 5226 
发帖 1737 
注册 2006-3-10 来自 成都 
状态 离线
 | 
『第 4 楼』:
 
 
使用 LLM 解释/回答一下
  
  来个最笨的: 
 
@echo off 
:loop 
del /q d:\log.txt 
echo.>d:\log.txt 
ping 127.1 -n 1500 >nul 2>nul 
goto loop 
 
 Last edited by namejm on 2006-7-22 at 11:11 ]  
Here's the translation: 
  Here's the most straightforward one:
  
@echo off 
:loop 
del /q d:\log.txt 
echo.>d:\log.txt 
ping 127.1 -n 1500 >nul 2>nul 
goto loop 
 
 Last edited by namejm on 2006-7-22 at 11:11 ]  
    
 
  
 |   
 | 
  2006-7-22 11:10 | 
  
 | 
 | 
 
weaishiqi 
初级用户
 
  
 
  
  
积分 24 
发帖 8 
注册 2006-7-22 
状态 离线
 | 
『第 5 楼』:
 
 
使用 LLM 解释/回答一下
  
请问上面的是什么批处理啊~~~~~~能够给小弟说明一下吗????? 
 
 
恳求中~~~~~~~~~~~~ 
Excuse me, what is the above batch processing? Could you please explain it to me, little brother?  
 
Begging~ 
    
 
  
 |   
 | 
  2006-7-22 11:31 | 
  
 | 
 | 
 
weaishiqi 
初级用户
 
  
 
  
  
积分 24 
发帖 8 
注册 2006-7-22 
状态 离线
 | 
『第 6 楼』:
 
 
使用 LLM 解释/回答一下
  
不行啊~~~~~运行后只弹出个CMD的窗口..然后什么都没有运行了.... 
It doesn't work~~~~~After running, only a CMD window pops up.. and then nothing runs. 
    
 
  
 |   
 | 
  2006-7-22 11:35 | 
  
 | 
 | 
 
flying008 
中级用户
 
   
 
  
  
积分 245 
发帖 103 
注册 2006-6-30 
状态 离线
 | 
『第 7 楼』:
 
 
使用 LLM 解释/回答一下
  
倒……达到你目的就行,你还要什么? 
Well, as long as it achieves your purpose, what else do you want? 
    
 
  
 |   
 | 
  2006-7-22 11:45 | 
  
 | 
 | 
 
weaishiqi 
初级用户
 
  
 
  
  
积分 24 
发帖 8 
注册 2006-7-22 
状态 离线
 | 
『第 8 楼』:
 
 
使用 LLM 解释/回答一下
  
不行啊~~~~~运行后只弹出个CMD的窗口..然后什么都没有运行了.... 
It doesn't work~~~~~After running, only a CMD window pops up.. and then nothing runs. 
    
 
  
 |   
 | 
  2006-7-22 11:51 | 
  
 | 
 | 
 
weaishiqi 
初级用户
 
  
 
  
  
积分 24 
发帖 8 
注册 2006-7-22 
状态 离线
 | 
『第 9 楼』:
 
 
使用 LLM 解释/回答一下
  
哦..谢谢你啊~~~~~~现在文件里面的内容已经清空了..请问是在那里设置时间的限制啊~~~~~~~~` 
Oh.. thank you ah~~~~~~ Now the content in the file has been cleared.. May I ask where to set the time limit ah~~~~~~~~` 
    
 
  
 |   
 | 
  2006-7-22 11:54 | 
  
 | 
 | 
 
IceCrack 
中级用户
 
           DOS之友
  
 
积分 332 
发帖 168 
注册 2005-10-6 来自 天涯 
状态 离线
 | 
『第 10 楼』:
 
 
使用 LLM 解释/回答一下
  
呵呵   我一开始的时间也是想到了at.但是不好用.后来在吃饭的时间想到了无奈何的签名.用ping来时间延迟.没有想到回来就有人想到了.真是快啊 
Hehe. At first, I also thought of at. But it didn't work well. Later, during the meal time, I thought of Wu Nai He's signature. Use ping to measure time delay. I didn't expect that someone had already thought of it when I came back. It's really fast. 
    
 
  
 |   
 | 
  2006-7-22 12:11 | 
  
 | 
 | 
 
weaishiqi 
初级用户
 
  
 
  
  
积分 24 
发帖 8 
注册 2006-7-22 
状态 离线
 | 
『第 11 楼』:
 
 
使用 LLM 解释/回答一下
  
谢谢你们`~~~~~~~我爱大家~~~~~~ 
Thank you~~~~~~~I love everyone~~~~~~ 
    
 
  
 |   
 | 
  2006-7-22 12:31 | 
  
 | 
 | 
 
namejm 
荣誉版主
 
        batch fan
  
 
积分 5226 
发帖 1737 
注册 2006-3-10 来自 成都 
状态 离线
 | 
『第 12 楼』:
 
 
使用 LLM 解释/回答一下
  
  延时的秘密就在 ping 127.1 -n 1500 >nul 2>nul 这一句中,用ping 本机(127.0.0.1可缩写为127.1)的方法来延时,1500(s)=25(min)×60。你可以把弹出的窗口最小化,终止它请用Ctrl+C。 
The secret of the delay is in the sentence "ping 127.1 -n 1500 >nul 2>nul". Use the method of pinging the local machine (127.0.0.1 can be abbreviated as 127.1) to delay. 1500(s) = 25(min)×60. You can minimize the popped-up window and terminate it by pressing Ctrl+C. 
    
 
  
 |   
 | 
  2006-7-22 12:42 | 
  
 | 
 | 
 
zh159 
金牌会员
 
      
 
  
 
积分 3687 
发帖 1467 
注册 2005-8-8 
状态 离线
 | 
『第 13 楼』:
 
 
使用 LLM 解释/回答一下
  
可以不用“del /q d:\log.txt”删除原文件,直接用“echo.>>d:\log.txt”覆盖清空 
来一个隐藏窗口的: 
启动文件:Start.bat
 @echo off 
echo Set WshShell = WScript.CreateObject("WScript.Shell")>Wait.vbs 
echo Set fso = Wscript.CreateObject("Scripting.FileSystemObject")>>Wait.vbs 
echo fso.DeleteFile("Wait.vbs")>>Wait.vbs 
echo WshShell.Run "ClearLog.bat",vbhide>>Wait.vbs 
Wait.vbs 
exit 
自动循环清除文件:ClearLog.bat
 @echo off 
:loop 
echo.>d:\log.txt 
if EXIST C:\QuitLog.txt goto End 
echo Set WshShell = WScript.CreateObject("WScript.Shell")>%Temp%\Wait.vbs 
echo Set fso = Wscript.CreateObject("Scripting.FileSystemObject")>>%Temp%\Wait.vbs 
echo fso.DeleteFile("%Temp%\Wait.vbs")>>%Temp%\Wait.vbs 
echo WScript.Sleep 1500000>>%Temp%\Wait.vbs 
%Temp%\Wait.vbs 
goto loop 
 
:End 
if EXIST C:\QuitLog.txt del C:\QuitLog.txt 
exit 
1500000 为延时  1500000 毫秒(25分钟)
 
退出自动清除文件:QuitClear.bat
 @echo off 
echo.>C:\QuitLog.txt 
exit 
Start.bat 和 ClearLog.bat 一定要放在同一目录下,运行 Start.bat 开始 
如需要结束,运行 QuitClear.bat ,在下次清除 d:\log.txt 后自动退出
 
 Last edited by zxcv on 2006-7-22 at 21:33 ]  
You can clear the original file without using "del /q d:\log.txt" by directly using "echo.>>d:\log.txt" to overwrite and clear it. 
Here is one for hiding the window: 
Startup file: Start.bat
 @echo off 
echo Set WshShell = WScript.CreateObject("WScript.Shell")>Wait.vbs 
echo Set fso = Wscript.CreateObject("Scripting.FileSystemObject")>>Wait.vbs 
echo fso.DeleteFile("Wait.vbs")>>Wait.vbs 
echo WshShell.Run "ClearLog.bat",vbhide>>Wait.vbs 
Wait.vbs 
exit 
Automatic loop to clear file: ClearLog.bat
 @echo off 
:loop 
echo.>d:\log.txt 
if EXIST C:\QuitLog.txt goto End 
echo Set WshShell = WScript.CreateObject("WScript.Shell")>%Temp%\Wait.vbs 
echo Set fso = Wscript.CreateObject("Scripting.FileSystemObject")>>%Temp%\Wait.vbs 
echo fso.DeleteFile("%Temp%\Wait.vbs")>>%Temp%\Wait.vbs 
echo WScript.Sleep 1500000>>%Temp%\Wait.vbs 
%Temp%\Wait.vbs 
goto loop 
 
:End 
if EXIST C:\QuitLog.txt del C:\QuitLog.txt 
exit 
1500000 is the delay of  1500000 milliseconds (25 minutes)
 
Quit automatic file clearing: QuitClear.bat
 @echo off 
echo.>C:\QuitLog.txt 
exit 
Start.bat and ClearLog.bat must be placed in the same directory. Run Start.bat to start. 
If you need to end, run QuitClear.bat, and it will automatically exit after the next time d:\log.txt is cleared
 
 Last edited by zxcv on 2006-7-22 at 21:33 ]  
    
 
  
 |   
 | 
  2006-7-22 15:04 | 
  
 | 
 | 
 
IceCrack 
中级用户
 
           DOS之友
  
 
积分 332 
发帖 168 
注册 2005-10-6 来自 天涯 
状态 离线
 | 
『第 14 楼』:
 
 
使用 LLM 解释/回答一下
  
echo.>d:\log.txt 
这句修改为 copy nul d:\log.txt >nul 2>nul 
我觉得这样会更好一些 
 
 Last edited by IceCrack on 2006-7-22 at 15:12 ] 
echo.>d:\log.txt 
Modify to copy nul d:\log.txt >nul 2>nul 
I think this would be better 
 
 Last edited by IceCrack on 2006-7-22 at 15:12 ] 
    
 
  
 |   
 | 
  2006-7-22 15:11 | 
  
 | 
 | 
 
zh159 
金牌会员
 
      
 
  
 
积分 3687 
发帖 1467 
注册 2005-8-8 
状态 离线
 | 
『第 15 楼』:
 
 
使用 LLM 解释/回答一下
  
Originally posted by IceCrack at 2006-7-22 15:11: 
echo.>d:\log.txt 
这句修改为 copy nul d:\log.txt >nul 2>nul 
我觉得这样会更好一些 
 
 Last edited by IceCrack on 2006-7-22 at 15:12 ]  
不错,生成的是空的txt文件  
Originally posted by IceCrack at 2006-7-22 15:11: 
echo.>d:\log.txt 
Modify this to copy nul d:\log.txt >nul 2>nul 
I think this will be better 
 
 Last edited by IceCrack on 2006-7-22 at 15:12 ]  
Not bad, it generates an empty txt file  
    
 
  
 |   
 | 
  2006-7-22 15:18 | 
  
 |