MT::TaskMgr - MT class for controlling the execution of system tasks.





MT::TaskMgr defines a simple framework for the execution of a group of runnable tasks (individually declared as MT::Task objects). Each task is executed according to their defined frequency. Tasks that fail are logged to MT's log table.


Movable Type, being a publishing framework, can benefit greatly by having a system of tasks that can be run "offline". Unfortunately, many MT users don't have the luxury of scheduling these tasks using "cron" or other similar facilities some servers provide. To satisfy everyone, the task framework introduced here allows MT and third-party plugins to register tasks that can be executed whenever the task subsystem is invoked. This can happen a number of ways:

  • By a script: tools/run-periodic-tasks

    For those that do have a "cron" system, they can continue to run the tools/run-periodic-tasks script provided with Movable Type. This script now invokes the task subsystem to execute all available tasks instead of just the one for publishing scheduled posts.

  • By fetching an activity feed

    With the activity feeds MT serves, it will invoke the task subsystem first, then return the feed. This allows users without access to cron service to run scheduled tasks. Note however, that this mode is reliant upon the feed being pulled by some client. If the feed is not being accessed, then the tasks won't run either. A user can utilize a feed-reading online service to achieve "24x7" task service to keep their tasks running smoothly.

  • Other requests

    Some tasks, such as the expiration of junk records, may be conditionally executed. Junk feedback record expiration is a MT-defined task that executes when tasks are run, and also when a new feedback record is scored as junk.

Tasks are an excellent way to maximize MT performance and user experience. For example, a plugin that may need to retrieve or synchronize data with a remote server may choose to operate from a cache that is periodically kept up to date using a registered task.




Registers a new MT::Task object. If this method is called with a hashref, a MT::Task will be constructed using that data.


Runs all available pending tasks. If an instance of the TaskMgr is already found to be running (through use of a physical file lock mechanism), the process will abort.


Returns the TaskMgr singleton.



Prior to running any registered tasks, this callback is issued to allow any registered MT plugins to add additional tasks to the list or simply as a way to signal tasks are about to start. This callback sends no parameters, but it is possible to retrieve the active MT::TaskMgr instance using the instance method.


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