启用 Robocopy 日志

启用 Robocopy 日志

我有一项robocopy由 Windows 任务计划程序控制的作业,每 15 分钟运行一次,将文件从一台服务器移动到另一台服务器。根据 Windows 任务计划程序,该作业运行正常。但是 - 没有任何文件被移动。

以下是完整脚本:

net use v: \\serverone /user:UserName PassWord
robocopy v:\ "\\servertwo\folder" /MOV
net use v: /d /yes
exit

有没有办法将日志记录添加到 robocopy 作业中以捕获错误,以便我可以找到文件未被移动的原因?

答案1

来自 robocopy /?

::
:: Logging Options :
::
                 /L :: List only - don't copy, timestamp or delete any files.
                 /X :: report all eXtra files, not just those selected.
                 /V :: produce Verbose output, showing skipped files.
                /TS :: include source file Time Stamps in the output.
                /FP :: include Full Pathname of files in the output.
             /BYTES :: Print sizes as bytes.

                /NS :: No Size - don't log file sizes.
                /NC :: No Class - don't log file classes.
               /NFL :: No File List - don't log file names.
               /NDL :: No Directory List - don't log directory names.

                /NP :: No Progress - don't display percentage copied.
               /ETA :: show Estimated Time of Arrival of copied files.

          /LOG:file :: output status to LOG file (overwrite existing log).
         /LOG+:file :: output status to LOG file (append to existing log).

       /UNILOG:file :: output status to LOG file as UNICODE (overwrite existing log).
      /UNILOG+:file :: output status to LOG file as UNICODE (append to existing log).

               /TEE :: output to console window, as well as the log file.

               /NJH :: No Job Header.
               /NJS :: No Job Summary.

           /UNICODE :: output status as UNICODE.

因此我会尝试类似以下的方法:

robocopy v:\ "\\servertwo\folder" /MOV /V /LOG:file.log

答案2

Robocopy:命令行使用示例和开关

示例 13:仅将错误记录到文本文件中:

robocopy C:\Folder1 C:\Backup /NFL /NDL /NJH /NJS /NS /NC /NP >> log.txt

>> log.txt您可以使用来代替/LOG+:log.txt。LOG+ 会附加

相关内容