- 28 May 2024
- 3 Minutes to read
- Print
- DarkLight
Windows Task Scheduling
- Updated on 28 May 2024
- 3 Minutes to read
- Print
- DarkLight
In this section we will be setting up three repeating tasks that are critical to ContractInsight. These tasks are:
Scheduled Jobs- This task scheduler checks every hour to see if an email or task needs to be sent from the system. It also checks to see if any contracts are within their notification or expiration date window.
OCR- This goes through the system every hour and looks for new documents that were uploaded and OCR’s them. The OCR (Optical Character Recognition) process allows text search through every page. A normal upload of a document only shows searchable information from the first page. A document that has been through the OCR process allows a search through all pages.
Hangfire- This task should always be running. This runs many background processes throughout the entire application. Seeing an error like "can not connect to server" could mean your Hangfire task is not running.
Setting Up Scheduled Tasks
Open the Windows Task Scheduler. You will be creating 3 tasks and instructions for each one will follow.
Add a new task by performing the following steps:
1.) Click “Create Task” under the Actions tabs on the right-hand side (do not click on ‘Create Basic Task’)
2.) Provide the general information for this task (as shown in the image below) for each of the 3 use this wording:
- Name: ContractInsight Scheduled Jobs Description: Keep Alive
- Name: ContractInsight ocr Description: Keep Alive
- Name: ContractInsight hangfire Description: Keep Alive
3.) In the menu that appears in the above screenshot fill out the following:
a. Name: provide a pertinent display name for this task
b. Description: provide any optional description for this task
c. User/Group: provide the User/Group that will be used to execute this task
i. The user must be a local administrator to the server.
ii. Recommended to use a user whose password will not change (IE: a service account)
iii. Ensure that “Run whether user is logged on or not” is selected.
iv. Ensure that “Run with highest privileges” is selected.
4). Next, click on the “Triggers” tab to setup the schedule for this task.
To create a new trigger, click on the “New” button and the following screen will open:
Configure the following settings:
i. Set “Begin the task” to “On a Schedule” (usually the default)
ii. Set to “Daily” with recurring every “1” day
iii. Select “Repeat task every” and set to “1 hour” for a duration of “1 day” (For Hangfire, "Repeat task every" should be set to "30 Minutes" for a duration of "1 day")
iv. Select “Stop task if it runs longer than” and set to “1 hour” v. Select “Enabled” (For Hangfire, leave this box unchecked)
vi. Click “OK”
5.) Click on the “Actions” tab.
To select an application, click on the “New” button and the following screen will open:
a. Click the “Browse” button to select the location (to specific scheduler being set up) of the application the location is:
C:/inetpub/wwwroot/core/ScheduleJob/CobbleStoneScheduledJobsKeepAlive.exe
C:/inetpub/wwwroot/ocr/CobbleStone.OCRCrawler.exe
C:/inetpub/wwwroot/Hangfire/Hangfire2.exe
b. Click “OK” after application is selected.
6.) Click on the “Settings” tab to open the following screen:
Ensure that “Stop the task if it runs longer than” is selected and set to “1 hour”. (For Hangfire, leave this box unchecked)
Ensure that all information on the tabs covered is accurate and click on the “OK” button.
a. A prompt will appear requesting the password of the user account selected for this task.
b. The password MUST be provided for the task to be created successfully.
The Windows Scheduled Task will now be successfully set up to run along the defined interval. Once set test the following 2 tasks: Run Hangfire, then OCR, then refresh to see if running successfully.
Test Scheduled Job
Reopen the config file in core/schedule job in notepad (run as admin).
For testing go to and add XXXX after your url name (highlighted below). This SHOULD cause an error.
1. Execute the Task Scheduler for scheduled jobs.
a. Ensure that an error notification was sent to the email. It should have a url with X’s in it. The Error Message is generic.
b. Remove the X’s and save and repeat. This time no email should be sent.
2. Upon completion close the config file.