Some tips to help you schedule scripts to run unattended
Some programming experience required!
Below I have scheduled some simple scripts to run with the Windows task scheduler. Here are the scripts:
test_1.bat
echo [ %date% %time% ] test_1.bat ran >> "test.log"
call test_2.bat
test_2.bat
echo [ %date% %time% ] test_2.bat ran >> "test.log
The first script prints to a file “test.log” the date and time and then calls test_2.bat which also prints the date and time to the same “test.log” file. This provides a simple simulation of the real backup. Here we can be sure that the scheduler is setup correctly and we understand the elements needed to set up the real backup correctly.
- Start the Task Scheduler
-
- Select the Task Scheduler Library
- Add a new folder. I suggest BIM Server.
- Select your new folder
- Create a task
- General Tab: Give a name.
- General Tab: User must have Administrative rights
- General Tab: Run whether user is logged on or not
- General Tab: Run with highest privileges
- Triggers Tab: New
- New Trigger: Choose how often and when to start (since this is a test I have scheduled it to run one “One Time”, and the time I set to be a few minutes after I finished the scheduling)
- New Trigger: Make sure it is enabled
- New Trigger: Okay Dialog
- Actions Tab: New
- New Action: Browse for where the script is
- New Action: Set the “Start in” to the folder where the scripts are located (If you don’t set this only the first script will run –unless you add a path to every point where the “Call” command is used in the scripts)
- New Action: Okay Dialog
- General Tab: Okay
- General Tab: Add your password as required for the account that will run the task
- Wait for task to be run by scheduler, or force it to run by clicking on Run in the far right Actions panel. (I suggest you wait for the scheduler to do it for the first time to make sure you have everything set up right)
- Look at the contents of the “test.log” to make sure they indicate the time of the scripts should have run. If the file is not there, or the time is not consistent with when it ran, you need to go through the steps to find out what went wrong. (probably the “start in” folder was not set correctly)
- Now that you are comfortable with the test program. Set scheduling up for the real backup scripts. If the authority of the user is not high enough it is possible that the backups will not run.
- The real backup will take longer to run and most likely you will schedule it for some time in the middle of the night or early morning. In this case you might want to make sure that it runs correctly using “Run.”