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?
Best explained by example:
Here's a trivial job file, call it
sample.rcj
: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./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.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.)
/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.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.
How to use Job Files
Job files are used to save and reuse (usually) long robocopy command lines.
To create a Robocopy Job File
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
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:
To create job files without the source/destination dir
In this case use the following syntax:
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).
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.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.
Check the documentation in Technet.