Movable Type Documentation > Developer > Plugins

Registering Scheduled Tasks

Movable Type allows plugin developers to register tasks that should be executed outside the context of the main application. These tasks can be scheduled to occur at a designated frequency (specified in seconds).

The type of task that can be executed is not limited or bounded in any way.

sub init_registry {
    my $plugin = shift;
    $plugin->registry({
        tasks                    =>  {
            'MyCustomTask' => {
                label     => 'Do something every two minutes',
                frequency => 120,
                code      => \&execute_task,
            },
        },
    });
}

sub execute_task {
    # no input is passed to this callback
    # do something
}

When registering a scheduled task, the following properties must be specified:

  • label - the display name of the scheduled task as it will appear in the application (e.g. the Activity Log)
  • frequency - the number of seconds to wait between executing the task
  • code - a reference to a subroutine or code block that will be executed when the scheduled task is triggered

Turning on Scheduled Tasks

Scheduled tasks are managed and executed by a script that is shipped with Movable Type. This script called run_periodic_tasks.pl should be added your crontab (in Unix) or to your list of Scheduled Tasks (in windows).

This page was last updated on 2007-07-24, 23:08.  

Submit a User Contributed Note

User contributed notes are a great way to share the knowledge you have gained in using Movable Type.

If you have a technical question or problem, please visit Movable Type Support.

(If you haven't left a note here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)