Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Some simple and practical BAT scripts on IDC business server

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

The script can search and clean up the specified error log files, and of course, with a little modification, you can achieve other corresponding complex functions.

@ echo off

:: author: by jerry

Set webroot=E:\ wwwroot

Set "Ymd=%date:~,4%-%date:~5,2%-%date:~8,2%"

Set "Hms=%time:~0,2%-%time:~3,2%-%time:~6,2%"

Set DT=%Ymd%-%Hms%

For / f "usebackq tokens=1 delims="% an in (dir / b% webroot%) do call: err_del% a

Echo -% DT% del err_log payment packages-> > dellog.txt

Filter out error_log.php by rem

: err_del

Set DirName=%1%

If exist% webroot%\% DirName%\ web\ caches\ error_log.php (call: screen)

Goto: eof

Rem deletes the error_log.php file

: screen

Del% webroot%\% DirName%\ web\ caches\ error_log.php

Echo% webroot%\% DirName%\ web\ caches\ error_log.php > > dellog.txt

Goto: eof

The following script implementation is available when transferring the IDC server site (restoring the server site) from the specified current copy to the corresponding directory.

:: DIY Copy To Specially Directories

:: Author: jerry

Date:2018-6-21

@ echo off

:: create variables

Set pathwww= "E:\ wwwroot"

:: get the directory name and store it in a temporary file for easy viewing

Dir / b pathwww% > tmp.txt

:: loop performs the copy operation, looping the directory name as the number of loop variables.

For / f% I in (tmp.txt) do (

Xcopy E:\ wwwrootbackup\% I\ www* E:\ wwwroot\% I\ web* / y / E)

Echo. & pause

Exit

The following script deletes the transaction log before the specified date

@ echo off

Set SrcDir=F:\ mysqlbak

Set DaysAgo=185

Forfiles / p% SrcDir% / d -% DaysAgo% / c "cmd / c del / f / Q / a @ path & & rd / s / Q @ path" > > delete_old_backup.log

The following script implements a compressed backup operation for the database.

@ echo off

Echo.

Echo MySQL database backup script

Echo

Echo.

Echo backup date:% date%

Echo backup time:% time%

Echo.

Echo

Set "Ymd=%date:~,4%-%date:~5,2%-%date:~8,2%"

Set bakdir= "D:\ MySQL51\ data"

Echo is entering the MySQL directory. Note: for directories with spaces, put quotation marks on the command line. "C:\ Program Files"

Cd "D:\ MySQL51"\ bin

Echo is stopping MySQL. Please wait a moment.

Net stop MySQL

Echo is backing up data. Please wait a moment.

If not exist "F:\ mysqlbak\% Ymd%" mkdir "F:\ mysqlbak\% Ymd%"

For / f "usebackq tokens=1* delims=/"% an in (dir / b% bakdir%) do "C:\ Program Files (x86)\ WinRAR\ WinRAR.exe" a-ep1-R0-exit-"F:\ mysqlbak\% Ymd%\% a.rar"% bakdir%\% a

Echo database backup completed, restarting MySQL, please wait a moment.

Net start MySQL

Echo MySQL startup completed

Echo.

Delete the file that contains the specified content, or use it to clean up the wooden code file, etc.

@ echo off

Set webroot=E:\ wwwroot

For / f "usebackq tokens=1 delims="% an in (dir / b% webroot%) do call: Del_Index% a

Filter out index.html by rem

: Del_Index

Set DirName=%1%

If exist% webroot%\% DirName%\ web\ index.html (call: screen)

Goto: eof

Rem deletes the index.html file with "

: screen

Find ""% webroot%\% DirName%\ web\ index.html

If errorlevel%==0 (del% webroot%\% DirName%\ web\ index.html)

Goto: eof

Delete all folders (including subfolders and contents) and file operation methods under the specified directory

@ echo off

Set / p cxname= Please enter the website name directory to be cleaned:

For / f "delims="% an in ('dir E:\ wwwroot\% cxname%\ www / b / AD') do (

Rd "E:\ wwwroot\% cxname%\ www\% a" / Q / s

)

Del E:\ wwwroot\% cxname%\ www* / f / s / Q > nul

Echo end...

Pause

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report