Scheduling Scripts to run at a Time Of Day with the Scheduler.
A Script is composed of one or more command Steps
which execute in sequence or can be timed to fire at a specified time.
You can run a Script manually by pressing Run Script button in the Automator window (Figure 2).
To get started with Scripts, read this page and look at the Script samples .
Sequential order - Each Step executes in sequence, waiting for the previous Step to complete. (when no time control is enabled).
Offset Time - The Step executes after a specified delay (offset) from the instant that the containing Script starts to run. Offset Times can be set to Auto Reset causing its timer to be reset everytime the Step executes. Timer auto-resets continue until the Script is stopped.
Scheduled Time - The Step executes at a specified time of day. This is only used by the Scheduler..
Offset Time: A Step will execute after a specified amount of time from the instant its containing Script starts to run. This is the best method for making sounds play concurrently. For example, set Offset Time to 2 seconds then the Step will execute 2 seconds after the Script starts to run.
Schedule Time: A Scheduled Step will execute at its specified time of day. It is ONLY executed by the Scheduler. It is not added to the Scheduler Plan until its containing Script starts to run. It is ignored when you run the Script manually.
A Step is treated as a simple sequential Step, when neither Offset Time nor Schedule Time are enabled.
Steps with equivalent Offset Times will start to execute simultaneously.
Steps with an Offset Time of zero (0) will execute immediately when the Script starts.
Pausing a Script that has Offset Timed Steps, will cause timing of those Steps will be invalidated. The timing of Step execution is not recalculated for the pause duration. When a Script is 'Paused', any Offset timed Steps that time out (Offset expires) are lost (not executed) Unexpected results are likely but the Script will continue to run when 'Resume' is clicked.
A Delay Steps are always executed as sequential Steps.
Play Step (looping): Playing a Sound Item that is setup to Loop (in the Play Modifiers) is a special case. A looping sound never finishes until you manually hit the Stop button. So it will prevent any subsequent Steps from executing. If you use a Looping sound, you will need to Stop the Script manually.
If a Script is detected repeating itself rapidly in a very short time span, the Automator will assume it is in a Runaway
condition and abort it.
Under certian conditions, you could create a Script that spins out of control, repeating itself as rapidly as your CPU can process it. This is usually associated with a Script set to Loop or Repeat and composed of timed Steps (ex Offset Timed Steps). The Script Editor detects and warns about obvious cases, but not all problems can be detected at edit time.
If a Script is detected as running in an infinite Recursion loop, the Automator will abort it.
This can happen if you are not careful with 'Run Script' Steps in your Scripts. For example, if you run Script A in Listing 2, it would cause a Recursion loop (A runs B; B runs A; A runs B; ad infinitum...).
If not stopped, the two Scripts would continue to run each other until the computer runs out of memory.
Figure 1. Script Recursion
Listing 2. Recursive Scripts
Name: Script A
Steps:
1. Run Script (Script B)
Name: Script B
Steps:
1. Run Script (Script A)