Template level External Article ID
KBA00020712
Issue
This article covers how to create a scheduled task report in the Windows environment
Resolution
Steps to create a scheduled task report in Windows:
- Copy the report from the rpt directory to the custom directory
- To find that directory, log into Spillman and shell out using sh at the command line
- At the command prompt type cd %FORCEDIR%. The FORCEDIR is a location that you may get to the Custom and rpt directory by typing: cd custom or cd rpt
- You can then use the cp command to copy that file or use windows explorer and browse to that directory. Give it a name that you can recognize like xxxxxxx.cron , substituting the name for the x's. If you would like you can modify the filename to something that lets you know what it is. For instance rplwdail-nypd.cron
- Modify the report
- Open the newly created report file in a plain text editor such as notepad. Modify the report by creating the p-variables the same way you would in creating a Unix cron
- For help modifying the report consult the articles titled:
How to create Unix or Linux cron reports
How to choose the time ranges for a Cron Report? - Save the report
- Create a batch file
- In the custom directory create a file named xxxxxx.cronrep.bat, substituting the report name for the x's
- Here is an example of batch file contents:
E:\SpillmanServer\app\bin\SpillmanEnv.exe -dbname=live
E:\SpillmanServer\app\perl\bin\perl.exe -MCtperl
E:\SpillmanServer\app\force\custom\rpjmcats.rcron2
E:\SpillmanServer\rpjmcats.rcron2.txt 2
E:\SpillmanServer\app\force\log\rpjmcats.rcron2.err
- The name of your report. In this example it is rpjmcats.rcron2
- The output location of your file. In this example that is the path after the first >
- The error output of your file. In this example it is the path after the 2>
NOTE: The above example will produce output to a text file. If you would like to output to a printer you could add something like:
print /d:\\printserver\sharenamedrive:\path\filename
You would need to replace the printer and path information as needed - Replace all instances of rpjmcats.rcron (including rpjmcats.rcron2.txt and rpjmcats.rcron2.er) with the name of your report - the customized version for the scheduled task which should be in %FORCEDIR%\custom
- This should be saved in the %FORCEDIR%\custom directory to avoid being overwritten during patch process. It needs to be saved in the following format:
*********.cronrep.bat (where ********* is the report name). I.e., rpjmcats.cronrep.bat
- Create the Scheduled Task
- To open Scheduled Tasks, click Start --> click on the Windows icon --> Windows Administrative Tools --> Task Scheduler
- - Click Task Scheduler to view the Task Scheduler program
- You can also type Task Scheduler in the search bar next to the Windows icon to find the Task Scheduler, and then click on Task Scheduler to open the program
- Click Create Basic Task
- Type a name for the task
- Click Next in the first dialog box
- Then choose one of the following options. When complete click Next:
Daily
Weekly
Monthly
One time only
When my computer starts (before a user logs on)
When I log on (only after the current user logs on)
- Specify the information about the day and time to run the task, and then click Next. The information about the day and time to run the task vary depending on the selection that you made in the previous wizard dialog box. For example, if you chose Weekly, you must indicate the day of the week, the time and if the task should run every week, every 2 weeks, every 3 weeks and so on
- Next select what you want the task to do:
- Next select the program/script to run (in this case the .bat created earlier) and any arguments to pass through the .bat or script
- Click Next, and then click Finish after you verify the choices that you have made
- You may need to setup a username and password but by default it runs under the current profile
For more info on creating windows tasks see:
https://technet.microsoft.com/en-us/library/dd851678.aspx
To test:
- Go to the command line using your Start button --> run --> and type cmd --> hit Enter
- At the command prompt paste the contents of the batch file onto the command line and hit Enter. This will test the script (to paste on a windows command line you have to right-click and select paste)