21

What does the Job Options of RoboCopy do? And what exactly does the /MON and /MOT switches do? How can I use them? I don't understand them, and can't find any examples on how to use them.

  • /MON:n - MONitor source; run again when more than n changes seen.
  • /MOT:m - MOnitor source; run again in m minutes Time, if changed.

Does this mean that it will run one time first and then keep running after it finishes and run again if a change happens somewhere down in the filestructure or when something have changed and a time has passed?

  • /JOB:jobname - take parameters from the named JOB file.
  • /SAVE:jobname - SAVE parameters to the named job file
  • /QUIT - QUIT after processing command line (to view parameters).
  • /NOSD - NO Source Directory is specified.
  • /NODD - NO Destination Directory is specified.
  • /IF - Include the following Files.

What is a job file? What is the /NOSD and /NODD switches for?

  • Great questions AND until I saw your tags I hadn't realized robocopy is part of windows 7. :-) – Chris_K Aug 18 '09 at 19:19
  • Thanks! Think it is part of Vista as well, but I'm using Windows 7, so slapped it on there. I didn't know about this tool at all a couple of days ago :D – Svish Aug 18 '09 at 20:00
  • 1
    Robocopy has been included standard since Windows Vista and Windows Server 2008. Prior to that, it has publicly available since v1.7 as a tool in the Windows Resource Kits since 3.51 (and prior to that, it was known to MS employees as "that awesome copy utility that Kevin wrote...") – Jessica McKinnon Aug 26 '09 at 17:35
6

Does this mean that it will run one time first and then keep running after it finishes and run again if a change happens somewhere down in the filestructure or when something have changed and a time has passed?

Yes. /MON counts number of files changed; /MOT counts time.

I've been afraid to ever try these options, since the docs say how to START these jobs, but not how to STOP them. They might become invisible, unstoppable scheduled tasks, for all I know.

This page indicates it runs until you interrupt the running job, e.g., with control-C.

(Added as an answer instead of as a comment, because StackExchange doesn't allow me to write comments without 50 reputation, and I have 1 reputation after 3 years.)

6

Best explained by example:

Here's a trivial job file, call it sample.rcj:

:: Source Directory :
    /SD:C:\Documents and Settings\  :: Source Directory.

:: Destination Directory :
::  On command line

:: Copy options :
    /E      :: copy Subdirectories, including empty ones.

It specifies options to copy the c:\Documents and Settings directory of the current machine to an unspecified location.

Here's how you'd use it to copy to the destination specified in the %DEST% environment variable, adding logging to the %LOG% file.

robocopy /nosd %DEST% /log+:%LOG% /job:sample

/NOSD is given because the source is specified in the job file.

You can play around with creating a robocopy command on the command line, then when you're happy it's doing what you want, run it again with /SAVE to save the options to a file.

/QUIT parses the options and will complain if you've got something wrong (invalid options, source doesn't exist) but doesn't actually do anything.

I would guess that /IF would let you include a file of options in addition to the job itself? (In my example, I could have put the /LOG option in a file and included it with /IF.) Just guessing there, though.

5

/MON scans the source and copies when it detects changes. /MOT reruns again in n minutes, and copies any detected changes

/JOB allows you to specify the options in a text file, in the event you have lots of options (like exclusions).

Wish I knew what /NOSD and /NODD did as I have never had a reason to use them.

  • Could you create an example of using that /JOB switch? I can't get it to work... – Svish Aug 18 '09 at 20:01
  • the /job file contains a list of switches (one per line) and their parameters. you can also use the /save switch to output a job file (.rcj) for later use – shufler Aug 20 '09 at 18:08
  • /MOT reruns every n minutes only if there where changes (see manual: "Monitors source, and runs again in M minutes if changes are detected") – ndemou Jan 28 '18 at 8:53
3

From: http://www-pc.uni-regensburg.de/systemsw/tools/robocopy.doc

Monitoring a Directory Tree Using the /MON:n and /MOT:m switches you can Monitor the source directory tree for changes, and copy changes as and when they occur. The /MON:n switch specifies the minimum number of changes that must occur before running again. The /MOT:m switch specifies the minimum time, in minutes, that must elapse before running again. If you only specify one of these switches, the other is assumed to have a value of 1.

When Monitoring is specified, Robocopy never terminates. Instead, it enters a loop that performs a normal Robocopy pass and then monitors the source directory tree for changes, until both n changes have been detected and m minutes have elapsed. When both conditions are met, another Robocopy pass is started. This whole process of copying and monitoring is repeated, ad infinitum, until the user manually terminates the Robocopy process.

As a minimum, Robocopy monitors the source directory tree for changes to file and directory names, sizes, and last write times. If attributes are to be copied Robocopy will also monitor the tree for attribute changes. Similarly, if security information is to be copied, Robocopy will also monitor the tree for security changes.

Consequently, a user performing an edit and saving a single new file, for example, may cause multiple changes of various types to be reported back to Robocopy. Therefore some experimentation may be required to determine appropriate threshold values for /MON and /MOT for each Robocopy job, especially those monitoring busy trees.

  • Hmm, so then it can be used to detect renames and moves. But when it does detect such a change in the tree, does it copy the file to the new name/location and delete it from the old (thus performing unnecessary writes), or can it rename/move it? – Synetech Sep 4 '13 at 19:54
  • Chrome flags this doc file as malware! – Aardvark Apr 14 '15 at 20:27
1

As an example, I use the /MOT switch to keep a DR file system up-to-date with a copy every 10 minutes. I start robocopy at 12am with a scheduled task and it runs all day copying any changes every 10 minutes. The scheduled task is set to stop itself after 23h55m and then robocopy is started by the next day's task at 12am again.

Although robocopy does indicate the number of changes as it waits for the 10 minute period to expire, it still scans the entire source folder structure you've pointed it to. So best to narrow the source structure down with a few folder exceptions (/XD <folder>) if you can.

  • Care to share your script? – Svish Jul 8 '10 at 16:49
0

Another simple way to do it is to just use /MIR switch and schedule your bat file to run it over and over again. It will only make the change based on source side. You need to run a full copy first.

Check the log file you will see the results. also use the /MT switch for Multi-threading.Make the copy faster.

0

How to use Job Files

Job files are used to save and reuse (usually) long robocopy command lines.

To create a Robocopy Job File

ROBOCOPY C:\SRC C:\DST ...other.robocopy.options... /SAVE:TEST /QUIT

This will create a Robocopy Job File named TEST.RCJ with all the Robocopy options you specified before the /SAVE switch and then quits without actually performing the copy.

To use one or more Job Files

ROBOCOPY /JOB:TEST /JOB:JOBFILE2 ...other.options...

To view or edit the job file

Just open it with a text editor. The format is self-explanatory.

To test job files

If you want to test your edits or if you're combining multiple job files and wonder what the final result is run this:

ROBOCOPY /JOB:JOBFILE1 /JOB:JOBFILE2 /QUIT

To create job files without the source/destination dir

In this case use the following syntax:

ROBOCOPY /NOSD /NODD ...options... /SAVE:TEST /QUIT

Apparently /NOSD and /NODD stand for NO Source Dir and NO Destination Dir.

You should also use these switches when running job files that defines either the source or the destination because robocopy will complain if you enter it again in the command line.

About /MON and /MOT

Your understanding of the manual is correct. Robocopy keeps running detecting and acting on any changes until you terminate it (e.g with Ctrl-C).

-1

Check the documentation in Technet.

  • 1
    The documentation there doesn't say anything more than what I put up in my answer there. At least as far as I can see... – Svish Sep 2 '09 at 11:30
  • I see what you mean, sorry. The documentation was much better before it became an "official" product. – John Gardeniers Sep 2 '09 at 11:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.