Windows periodically deletes log files that are n days before the specified path

Source: Internet
Author: User

The contents of the Windows under Bat script file are

1. Delete all files up to 5 days before the specified path

.

@echo offset Srcdir=e:\work\gitset daysago=5forfiles/p%srcdir%/s/m *.*/d-%daysago%/C "cmd/c del/f/q/a @path"
2. Delete all log files up to 5 days before the specified path
@echo Offset Srcdir=e:\work\git//specified path: 5 days ago Set daysago=5//5 days ago forfiles/p%srcdir%/s/m *.log/d-%daysago%/C "Cmd/c del /f/q/A @path "

*.log to filter the file format, also if you delete jpg picture format file, here can be replaced by . jpg

3. Windows timed to run BAT file

1) in WIN10 system, select Computer Management-"System Tools-" Task Scheduler, create tasks

2) in the "Create Task" box that pops up, the general settings

3) in the trigger-"new, and set the time and frequency of the scheduled operation

4) operation-"New-" open the well-written bat script file and click OK to save

Then return to the Computer Management interface, the System Tools-"Task Scheduler-" Task Scheduler can find the "Timed automatic deletion" task.

Windows periodically deletes log files that are n days before the specified path

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.