In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
The database backs up files every day, but only needs to keep the backup for seven days. Write a batch script file to automatically delete the files from seven days ago and set up scheduled tasks.
Automatic deletion of files requires the forfiles command
Forfiles parameters:
/ p specified path
/ s includes subdirectories
File name mask for / m lookup
/ d specifies the date, with absolute and relative dates, where-7 refers to 7 days before the current date
The command line run by / c represents the commands executed for each file. The command string should be enclosed in double quotes.
The default command is "cmd / c echo @ file". The following variables can be used in the command string:
@ file-returns the file name.
@ fname-returns a file name without an extension.
@ ext-returns only the extension of the file.
Path-returns the full path to the file.
Relpath-returns the relative path to the file.
Isdir-returns "TRUE" if the file type is a directory, or "FALSE" if it is a file.
Fsize-returns the file size in bytes.
Fdate-returns the date the file was last modified.
Ftime-returns the time when the file was last modified.
Create a new notepad file, enter the following command, and name the file "Delete the file that was backed up 7 days ago. Bat". Note the path where the file is located.
@ echo off # requires the password forfiles / p "C:\ autoscpfile\ data" / s / m * .bak / d-7 / c "cmd / c del / f @ path" forfiles / p "C:\ autoscpfile\ log" / s / m * .txt / d-7 / c "cmd / c del / f @ path"
Set up scheduled tasks after the script file is written
Open the task schedule on Windows server 2003
Start-> all programs-> attachments-> system tools-> Task schedule
Right-click the new scheduled task in the space, name the task "Delete backup 7 days ago", and double-click the task
Select browse, find the path to the batch file, and set the password, which is the login password of the user who executed the script
Set the time for the execution of the script, execute the script at 3:00 every day, and then click apply to determine
Open the task schedule on Windows server 2008 R2
Start-> Administrative tools-> Task Scheduler
In the action bar on the right, click create Task
Name the task, select the configuration, and run with the highest permissions
Select trigger, new
Select the new trigger, set the time for the task to execute, and determine
Select action, new
Click Browse, select the script path to be executed, start with the option to fill in the script path, and then determine
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.