+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / How Do I Create a reoccuring scheduled task?

How Do I Create a reoccuring scheduled task?

12 posts, 0 answered
  1. kevin
    kevin avatar
    1 posts
    Registered:
    11 Jul 2011
    03 Aug 2011
    Link to this post
    How do I make a task I inherit from the SheduledTask base class reoccur at a specified interval?
  2. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    03 Aug 2011
    Link to this post
    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;
            };

    Best wishes,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Seattle Web Group
    Seattle Web Group avatar
    29 posts
    Registered:
    03 May 2011
    23 Nov 2011
    Link to this post
    It looks like in the sample code at 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 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?
  4. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    28 Nov 2011
    Link to this post
    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,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Seattle Web Group
    Seattle Web Group avatar
    29 posts
    Registered:
    03 May 2011
    28 Nov 2011
    Link to this post
    Thank you for the clarification.  That is very helpful for the schedule task we're in the process of setting up.
  6. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    28 Nov 2011
    Link to this post
    Hi Seattle Web Group,

     I'm glad that helps. Let me know if any issues occur with it.

    Greetings,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Brett Whittington
    Brett Whittington avatar
    89 posts
    Registered:
    10 Aug 2012
    05 Mar 2013
    Link to this post
    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.
  8. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    22 Sep 2016
    08 Mar 2013
    Link to this post
    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
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. NimitV
    NimitV avatar
    68 posts
    Registered:
    06 Apr 2010
    18 Sep 2013 in reply to Stanislav Velikov
    Link to this post
    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
  10. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    22 Sep 2016
    23 Sep 2013
    Link to this post
    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
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Celso
    Celso avatar
    6 posts
    Registered:
    03 Jul 2015
    17 Jan
    Link to this post

    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

  12. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    22 Sep 2016
    27 Jan
    Link to this post
    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)
         };

    Regards,
    Stanislav Velikov
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
12 posts, 0 answered