![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-01 23:16 |
48,037 topics / 350,122 posts / today 2 new / 48,250 members |
| DOS批处理 & 脚本技术(批处理室) » [Closed] Regularly clear all contents of log.txt every 25 minutes |
| Printable Version 2,524 / 19 |
| Floor1 weaishiqi | Posted 2006-07-22 10:04 |
| 初级用户 Posts 8 Credits 24 | |
|
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 ] |
|
| Floor2 skyearth | Posted 2006-07-22 10:42 |
| 初级用户 Posts 13 Credits 34 | |
|
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
|
|
| Floor3 weaishiqi | Posted 2006-07-22 10:59 |
| 初级用户 Posts 8 Credits 24 | |
|
I don't know what an AT task instruction is~~~~~~~
|
|
| Floor4 namejm | Posted 2006-07-22 11:10 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
|
Here's the translation:
Here's the most straightforward one: [ Last edited by namejm on 2006-7-22 at 11:11 ] |
|
| Floor5 weaishiqi | Posted 2006-07-22 11:31 |
| 初级用户 Posts 8 Credits 24 | |
|
Excuse me, what is the above batch processing? Could you please explain it to me, little brother?
Begging~ |
|
| Floor6 weaishiqi | Posted 2006-07-22 11:35 |
| 初级用户 Posts 8 Credits 24 | |
|
It doesn't work~~~~~After running, only a CMD window pops up.. and then nothing runs.
|
|
| Floor7 flying008 | Posted 2006-07-22 11:45 |
| 中级用户 Posts 103 Credits 245 | |
|
Well, as long as it achieves your purpose, what else do you want?
|
|
| Floor8 weaishiqi | Posted 2006-07-22 11:51 |
| 初级用户 Posts 8 Credits 24 | |
|
It doesn't work~~~~~After running, only a CMD window pops up.. and then nothing runs.
|
|
| Floor9 weaishiqi | Posted 2006-07-22 11:54 |
| 初级用户 Posts 8 Credits 24 | |
|
Oh.. thank you ah~~~~~~ Now the content in the file has been cleared.. May I ask where to set the time limit ah~~~~~~~~`
|
|
| Floor10 IceCrack | Posted 2006-07-22 12:11 |
| 中级用户 Posts 168 Credits 332 From 天涯 | |
|
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.
|
|
| Floor11 weaishiqi | Posted 2006-07-22 12:31 |
| 初级用户 Posts 8 Credits 24 | |
|
Thank you~~~~~~~I love everyone~~~~~~
|
|
| Floor12 namejm | Posted 2006-07-22 12:42 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
|
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.
|
|
| Floor13 zh159 | Posted 2006-07-22 15:04 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
|
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 Automatic loop to clear file: ClearLog.bat @echo off 1500000 is the delay of 1500000 milliseconds (25 minutes) Quit automatic file clearing: QuitClear.bat @echo off 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 ] |
|
| Floor14 IceCrack | Posted 2006-07-22 15:11 |
| 中级用户 Posts 168 Credits 332 From 天涯 | |
|
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 ] |
|
| Floor15 zh159 | Posted 2006-07-22 15:18 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
Originally posted by IceCrack at 2006-7-22 15:11: Not bad, it generates an empty txt file |
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |