MT::Task - Movable Type class for registering runnable tasks.


    package MyPlugin;

    MT->add_task(new MT::Task({
        name => "My Task",
        key => "Task001",
        frequency => 3600, # at most, once per hour
        code => \&runner


An MT::Task object is used to define a runnable task that can be executed by Movable Type. The base object defines common characteristics of all tasks as well as the method to invoke it.

Normally, a plugin will construct an MT::Task object and pass it to the add_task method of the MT class:

    MT->add_task(new MT::Task({
        # arguments; see listing of arguments below



The following are a list of parameters that can be specified when constructing an MT::Task object.

  • key

    Defines a unique string for the task. This is used to manage a session record for the task. The task session record is kept to record the last time the task was executed. Session records are stored in the mt_session table with a 'kind' column value of 'PT' (periodic task).

  • name

    The name of the task. This is optional, but is used in recording error log records when the task fails.

  • frequency

    The frequency is a duration of time expressed in seconds. This defines how often the task is to be run. There is no guarantee that the task will be run this often; only that it will not be executed more than once for that period of time.

  • code

    The code to be executed when the task is invoked by MT::TaskMgr. This is a code reference and the routine is given the MT::Task instance as a parameter.


Initializes a MT::Task instance.


Called when running the task.


Gets or sets the unique key registered for the task.


Gets or sets the name registered for the task.


Gets or sets the execution frequency for the task (in seconds). The default frequency is 86400 which is daily.


Please see the MT manpage for author, copyright, and license information.