好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 知識庫 > 使用forfiles命令批量刪除N天前文件

使用forfiles命令批量刪除N天前文件

熱門標簽:玉林市機器人外呼系統(tǒng)哪家好 清遠百度地圖標注店鋪位置 雷霆電銷機器人怎么樣 如何弄地圖標注 電話機器人產(chǎn)品怎么樣 呼倫貝爾外呼系統(tǒng) 如何申請400電話業(yè)務mm 智能打電話機器人收費 電話機器人全國招商

在整理手上幾臺SQL SERVER 2000的數(shù)據(jù)庫備份時,一方面為了方便快速還原數(shù)據(jù)庫,另外一方面為了備份冗余、備份方式統(tǒng)一(先備份到本地,然后收上磁帶),將以前通過Symantec Backup Exec直接備份上帶的作業(yè)改成了如下方式:
    Step 1: 通過數(shù)據(jù)庫維護計劃將備份生成在本地磁盤M,完整備份保留2天,事務日志備份保留3天

            M:\DB_BACKUP\FULL_BACKUP
            M:\DB_BACKUP\LOG_BACKUP

    Step 2:  備份完成后通過Symantec Backup Exec將備份文件收上磁帶。
但是發(fā)現(xiàn)即使SQL SERVER 2000的數(shù)據(jù)庫維護計劃設置了刪除幾天前的備份文件,但是發(fā)現(xiàn)根本沒有刪除過期備份。于是只好使用dos命令來處理。剛開始想用forfiles命令,結果我搜索的時候,發(fā)現(xiàn)Windows 2000下沒有forfiles命令,后來通過從第三方復制過來,發(fā)現(xiàn)Windows 2000下也可以使用forfiles(如果不借助于forfiles命令,直接用批處理命令完成這個,那簡直痛苦死了)
關于forfiles命令的語法如下所示
 
C:\&;forfiles /?
FORFILES [/P pathname] [/M searchmask] [/S]
         [/C command] [/D [+ | -] {yyyy-MM-dd | dd}]
Description:
    Selects a file (or set of files) and executes a
    command on that file. This is helpful for batch jobs.
Parameter List:
    /P    pathname      Indicates the path to start searching.
                        The default folder is the current working
                        directory (.).
    /M    searchmask    Searches files according to a searchmask.
                        The default searchmask is '*' .
    /S                  Instructs forfiles to recurse into
                        subdirectories. Like "DIR /S".
    /C    command       Indicates the command to execute for each file.
                        Command strings should be wrapped in double
                        quotes.
                        The default command is "cmd /c echo @file".
                        The following variables can be used in the
                        command string:
                        @file    - returns the name of the file.
                        @fname   - returns the file name without
                                   extension.
                        @ext     - returns only the extension of the
                                   file.
                        @path    - returns the full path of the file.
                        @relpath - returns the relative path of the
                                   file.
                        @isdir   - returns "TRUE" if a file type is
                                   a directory, and "FALSE" for files.
                        @fsize   - returns the size of the file in
                                   bytes.
                        @fdate   - returns the last modified date of the
                                   file.
                        @ftime   - returns the last modified time of the
                                   file.
                        To include special characters in the command
                        line, use the hexadecimal code for the character
                        in 0xHH format (ex. 0x09 for tab). Internal
                        CMD.exe commands should be preceded with
                        "cmd /c".
    /D    date          Selects files with a last modified date greater
                        than or equal to (+), or less than or equal to
                        (-), the specified date using the
                        "yyyy-MM-dd" format; or selects files with a
                        last modified date greater than or equal to (+)
                        the current date plus "dd" days, or less than or
                        equal to (-) the current date minus "dd" days. A
                        valid "dd" number of days can be any number in
                        the range of 0 - 32768.
                        "+" is taken as default sign if not specified.
    /?                  Displays this help message.

Examples:

    FORFILES /?
    FORFILES
    FORFILES /P C:\WINDOWS /S /M DNS*.*
    FORFILES /S /M *.txt /C "cmd /c type @file | more"
    FORFILES /P C:\ /S /M *.bat
    FORFILES /D -30 /M *.exe
             /C "cmd /c echo @path 0x09 was changed 30 days ago"
    FORFILES /D 2001-01-01
             /C "cmd /c echo @fname is new since Jan 1st 2001"
    FORFILES /D +2014-12-15 /C "cmd /c echo @fname is new today"
    FORFILES /M *.exe /D +1
    FORFILES /S /M *.doc /C "cmd /c echo @fsize"
    FORFILES /M *.txt /C "cmd /c if @isdir==FALSE notepad.exe @file"
 
對應的中文提示信息如下所示:

語法
forfiles [/p Path ] [/m SearchMask ] [/s ] [/c Command ] [/d [{+ | - }] [{MM / DD / YYYY | DD }]]
參數(shù)
/p Path
指定Path ,表明要從哪里開始搜索。默認的文件夾是當前工作目錄,該目錄通過鍵入句號(.) 指定。
/m SearchMask
按照SearchMask 搜索文件。默認的SearchMask 是*.* 。
/s
指示forfiles 在子目錄中搜索。
/c Command
在每個文件上運行指定的Command 。帶有空格的命令字符串必須用引號括起來。默認的Command 是"cmd /c echo @file" 。
/d [{+ | - }] [{MM / DD / YYYY | DD }]
選擇日期大于或等于(+ )(或者小于或等于(- ))指定日期的文件,其中MM / DD / YYYY 是指定的日期,DD 是當前日期減去DD 天。如果未指定+ 或- ,則使用+ 。DD 的有效范圍是0 - 32768。
/?
在命令提示符下顯示幫助。
如下所示,由于Windows Server 2000下拷貝過來的forfiles命令的版本是V 1.1,使用參數(shù)必須為-p、-c、-m 而且參數(shù)后面不能有空格。

 

如下所示,delete_old_backup.bat 刪除2天前的完整備份、事務日志備份、以及維護計劃生成的日志文件。

echo --------------------------------------------- >>delete_old_backup.log 
 
echo Delete the backup log start at %Date% - %time% >>delete_old_backup.log 
 
rem Delete days. 
 
set DaysAgo=2 
 
rem delete old backup log files. 
 
set LogPath=M:\DB_BACKUP\ 
 
forfiles -p%LogPath% -m*.txt -d-%DaysAgo% -c"cmd /c del /q @FILE" >> delete_old_backup.log 
 
echo Delete the backup log Stop at %Date% - %time% >>delete_old_backup.log 
 
echo Delete the full backup start at %Date% - %time% >>delete_old_backup.log 
 
set FullBackupPath=M:\DB_BACKUP\FULL_BACKUP 
 
forfiles -p%FullBackupPath% -m*.bak -d-%DaysAgo% -c"cmd /c del /q @FILE" >> delete_old_backup.log 
 
echo Delete the full backup Stop at %Date% - %time% >>delete_old_backup.log 
 
echo Delete the log backup start at %Date% - %time% >>delete_old_backup.log 
 
set LogBackupPath=M:\DB_BACKUP\LOG_BACKUP 
 
forfiles -p%LogBackupPath% -m*.TRN -d-%DaysAgo% -c"cmd /c del /q @FILE" >> delete_old_backup.log 
 
echo Delete the log backup Stop at %Date% - %time% >>delete_old_backup.log 
 
echo --------------------------------------------- >>delete_old_backup.log

腳本編寫、測試成功后,然后設置Task Schedule,大體步驟如下步驟所示:

Step 1:在控制面板找到任務計劃,執(zhí)行任務計劃向導:

Step 2: 點擊“瀏覽”按鈕,選擇M:\DB_BACKUP\delete_old_backup.bat文件

Step 3:輸入任務的名稱,以及執(zhí)行任務的Schedule

Step 4:設置任務執(zhí)行的時間以及頻率

Step 5:輸入知曉計劃任務的賬號以及密碼

Step 6:完成任務計劃設置。

上面的bat主要是支持參數(shù)與日志的現(xiàn)實,確實不錯,其實核心代碼就是這樣的

forfiles /p "c:\backup" /d -10 /c "cmd /c echo deleting @file ...  del /f @path"

測試前最好備份一下數(shù)據(jù)

標簽:樂山 公主嶺 蕪湖 江西 臺州 三門峽 株洲 白銀

巨人網(wǎng)絡通訊聲明:本文標題《使用forfiles命令批量刪除N天前文件》,本文關鍵詞  使用,forfiles,命令,批量,;如發(fā)現(xiàn)本文內(nèi)容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《使用forfiles命令批量刪除N天前文件》相關的同類信息!
  • 本頁收集關于使用forfiles命令批量刪除N天前文件的相關信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 国产精品秘?入口在线看写真| 特级黄色毛片视频片子| 狠狠色噜噜色狠狠狠综合久久 | 2024三级大尺度电影| 欧美精品aV一区二区| 美女第一次处破女| 夫妻午夜免费影院| 免费h片在线观看网址最新| 光屁股趴办公室被老板打| 女人又爽?又黄?动漫下载| 玖玖在线资源站| 天天操夜夜骑| 99精品国产自在现线免费亚瑟| 中文字幕乱码Av视频| 乱肉短篇500篇阅读| 91精品国产91久久久久久麻豆 | 极品少妇蜜桃小泬| 嗯灬啊灬好深灬好硬啊灬无码网站 | 精品国产群3p交换在线| 午夜伦yy44880影院 导演| 最好看的2019年中文视频在线观看| 一木道一二三区精品| 99久久国产精品免费一区二区| 巜商务出差和女老板同房HD| 国产一级一级毛片| 小说h文| **一级毛片全部免| 激情另类偷拍亚洲小说| 女m接受程度自测表表格下载| 3p娇妻在客厅被弄到高潮| 国产高中生三级视频| 不要啊h| 乳色吐息无删减在线观看免费| 国产欧美日韩综合精品| 精品国产一区| 亚洲跨种族黑人xxx| japan小娇hdxxxx日本| 女人任你躁x7x7视频| 闷骚艳岳的婬乱生活| 日本毛茸茸| 亲密爱人1韩剧完整版|