Get the App
SLTechnology News&Howtos  ›  Servers  › 

Windows periodically cleans up specified directory files (keeps logs for specified days)

Shulou Source: shulou.com Published: 2022-06-02 17:56:50 10月03日 Update

1. Edit del60day.bat script and add the following:

Replace the specified directory and time according to actual needs, and only keep all files in the D:\DBbak directory for the last seven days.

#del60day.bat file forfiles /p "D:\DBbak" /s /m *.* /d -60 /c "cmd /c del @path"#clean.bat file forfiles /p "E:\tmp\LocalUser\jda" /s /m *.* /d -30 /c "cmd /c del @path"

save and exit

2. Join windows regular scheduling tasks

In win system, select Computer Management-> System Tools-> Task Scheduler to create a task

Configure the three pages of General, Trigger and Operation as required, as follows:

2.1, Configure General page, where the Runner is specified: Execute script regardless of whether the user is logged in or not

2.2 Configure Trigger page, specify script execution time schedule

2.3, configuration operation page, specify the written script

Click OK after all configurations are complete:

Tags: Configuration scripts pages files tasks directories general time system triggers three content actual tools users programs computers login management run Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft macOS MariaDB vpn NVidia