How Do I Create a reoccuring scheduled task?
How do I make a task I inherit from the SheduledTask base class reoccur at a specified interval?
Hello Kevin,
Here you can read how to create a task:
http://www.sitefinity.com/40/help/developers-guide/how-to-how-to-schedule-a-task-to-import-pop3-content-creating-the-scheduled-task-creating-the-task.html
Here you can read how to schedule a task:
http://www.sitefinity.com/40/help/developers-guide/how-to-how-to-schedule-a-task-to-import-pop3-content-creating-the-scheduled-task-scheduling-the-task.html
In order for this task to be recurring, in the constructor of the task, you should set the IsRecurring property to true:
PipeScheduledTask newTask =
new
PipeScheduledTask()
Key = myKey,
ExecuteTime = DateTime.UtcNow.AddSeconds(10),
IsRecurring =
true
;
;
It looks like in the sample code at www.sitefinity.com/.../how-to-how-to-schedule-a-task-to-import-pop3-content-creating-the-scheduled-task-creating-the-task.html the task is rescheduling itself at the end of the ExecuteTask() function. If this code is included, and the IsRecurring value is set as in your sample code will it create any problems? When the IsRecurring flag is set as in your sample code how often will the task run?
Hi,
You are correct - if the ExecuteTask() method is implemented like this, then each time it is called the task would get rescheduled and you do not need to set the property IsRecurring (actually I apologize that I misled you - it is better to implement it that way than setting the property to true).
Regards,Thank you for the clarification. That is very helpful for the schedule task we're in the process of setting up.
Hi Seattle Web Group,
I'm glad that helps. Let me know if any issues occur with it.
Greetings,How does this work if your sites app pool hasn't been started. For instance, if you stop your website and restart it but do not hit your site? Will the schedule task still kick off or will it wait until the site has been hit and then kick it off? Also, how is this functionality affected with a load balanced solution? I do not want each server kicking off an instance of a scheduled task to FTP a file to another location.
Hi,
How does this work if your sites app pool hasn't been started.
As soon as the website comes online if the execution time for a task is overdue due to the site downtime the task will execute af the earlies convenience.
Also, how is this functionality affected with a load balanced solution?
In load balancing the task will get executed from one of the servers inthe NLB setup, but after the execution if the task publishes a news item all other servers will be notified for the change, as if publishing news item trough the UI.
I do not want each server kicking off an instance of a scheduled task to FTP a file to another location.
Only one server will execute the task the server that will do it will be determined by the load balancing algorithm in windows server.
Kind regards,
Stanislav Velikov
the Telerik team
Hi Stanislav,
How often does Sitefinity check for scheduled tasks?
Are there any server requirements for scheduled tasks?
Will scheduled tasks run in the VS development server?
Thanks,
Steve
Hi Steve,
How often does Sitefinity check for scheduled tasks?
There is no periodical change an internal timer handles the scheduled task execution so each task starts its execution at the time it was supposed to. You can monitor the scheduled tasks that are pending for example in the database table sf_scheduled_tasks in column execue_time.
Are there any server requirements for scheduled tasks?
Depending on the server configuration and if the server allows access to the site trough proxy a scheduled task might not get executed and in this case go to Administration->Settings->Advanced->System->Service paths and fill in the textbox labeled WorkflowBaseUrl with the url of the site and save changed. This will make the scheduled tasks execute.
Will scheduled tasks run in the VS development server?
Yes.
Regards,
Stanislav Velikov
Telerik
Hi there,
This is something that also interests me, particularly, when I want to have, lets say, a task that executes every Monday at 3am (as an example). Using the Sitefinity scheduler how does one define this?
Best Regards
Hi,
In the execute task method body(ExecuteTask()) add logic that will set the time in which the next task me be executed. In general if the task is initially scheduled to execute in Monday add one week in a new scheduled task added in ExecuteTask method to schedule the next run after one week.
PipeScheduledTask newTask = new PipeScheduledTask()
Key = this.Key,
ExecuteTime = DateTime.UtcNow.AddHours(1)
;