Scheduling to run a macro on every hour
Asked Answered
N

2

5

Is there anyway to schedule a macro in Umbraco or a .ascx file to run every hour?

thanks

Naomanaomi answered 14/3, 2013 at 16:41 Comment(0)
F
7

There are two ways to run scheduled tasks in Umbraco:

  1. Add tasks to umbracoSettings.config. See Scheduled Tasks from the Umbraco Wiki.
  2. Use the TaskScheduler package.

TaskScheduler provides a nice interface to setup tasks in the Umbraco backend. You can schedule tasks to run at specific times and you can set the recurrence. It also can send emails when tasks are executed.

Adding tasks to umbracoSettings.config may be simpler. Below is an example:

<scheduledTasks>
    <!-- add tasks that should be called with an interval (seconds) -->
    <task log="true" alias="test60" interval="60" url="http://localhost/umbraco/test.aspx"/>
</scheduledTasks>
Friable answered 14/3, 2013 at 17:17 Comment(3)
+1 Good answer, I've added an additional tip on how to hook the schedulers into macros (rather than pages).Antechoir
Can I define a URL without specity hostname? For example: "/umbraco/test.aspx" or "~/umbraco/test.aspx"?Southwick
@riofly, no, unfortunately, I believe the url has to be absolute, not relative.Friable
A
0

If you want to run a macro, ascx (or cshtml for that matter) from code you can use the macroservice package. With this installed you can then run macros directly from code, using web services, WCF, setInterval/setTimeout from javascript etc. Would work well with @DouglasLudlow's (+1) suggestions for setting up Scheduled tasks.

Umbraco Macro Service exposes standard Umbraco Macros directly to the web for use in scripts or to provide direct data access to data using the already familiar Macro.

Similar to the Umbraco Base (and heavily borrowed against), Macro Service makes it easier to access your umbraco data for use in your javascript and other applications.

See the project page at http://our.umbraco.org/projects/backoffice-extensions/macroservice for more details.

Antechoir answered 15/3, 2013 at 10:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.