- Create a Custom Feed Reader with Blogger Blog List
- MultiBlog and Upgrading to MT4
- Get An Email List of All Authors On Your System
- Upgrading to MT4
- Creating a Google Toolbar Button for Your Blog
- Template Macros: The coolest template trick you don't know about
- How to Customize Default Styles in MT4
- Running Publish Queue under daemontools
- Fighting Hotlinkers with htaccess
- List Random Authors
- Share This Post in Movable Type 4
- How to Export Tags from Movable Type 3.3x
- Movable Type Scheduled Tasks
- Add Scrollbars to Image Popup Windows in Movable Type 4
- Install Movable Type 4 in Yahoo! Small Business
- Favicon and Gravatar in MT4
- Make Flickr's Blog This Feature Work with Movable Type 4.0
- Install Movable Type Under Windows (IIS)
- Upgrading to Movable Type 4 with MTCommentFields
- Tag Cloud on PHP in Movable Type 4
- Alternating Comment Styles with Movable Type 4
- Rotating Banner Ads in MT Using PHP
- Putting MT:MultiBlog to Work
- Create a Contact Form using MT4
- Working with Movable Type 4.0 Templates: Sidebar
Movable Type Scheduled Tasks
Wednesday, December 12, 2007Movable Type has a scheduled tasks system that is used to perform certain tasks on scheduled basis. Built-in tasks include expiring junk (spam) trackbacks and comments, and posting entries that were scheduled to to published at a certain date / time. Movable Type plugins can also use scheduled tasks, as some of my plugins do (including Visitor Stats Pro, Ajax Rating Pro, and Blog Janitor). One of the benefit of scheduled tasks is to improvement performance and user experience -- resource intensive functions can be run without making admins, authors, and commenters wait while they complete.
Triggering Scheduled Tasks
Scheduled task will only run when they are triggered. This is important. Even if a task is scheduled to run every hour, it scheduled tasks don't get triggered, the task will never run. By default Movable Type will trigger scheduled tasks in the following cases:
- You receive a junk (spam) comment or trackback. Note: this will only trigger the 'Junk expiration' task - it won't trigger plugin tasks.
- You view or download an XML "activity feed" (These feeds show up on with orange feed links on many screens of the admin MT interface, including entry and comment listings, and activity log).
- When the run-periodic-tasks script (found in the 'tools' directory of MT) is run via the command line or via cron.
Testing Scheduled Tasks
Here is an easily method that I use to test scheduled tasks and make sure they are running correctly:
- Go to System Overview > Activity Log.
- Click the "Activity Feed" link on the right side of the page.
- After the XML feed displays, hit the back button.
- Now refresh the System Activity Log.
- Read the recent log entries. If tasks were just triggered, there should be a message stating that tasks were run, along with the names of those tasks. In addition, some plugin tasks may post custom log messages to the Activity Log, providing more information about the task completed.
Note that in some cases, depending of the task, you may have to rebuild your pages after the task has run, in order to see the results of the task. One example of such a case is my Visitor Stats Pro plugin, in which a scheduled task tallies the page views of each entry, so that they can be displayed in a "Most Read Entries" widget that lists the most popular entries.
Setting Up a Cron Job
To ensure that scheduled tasks get triggered on a regular basis, I recommend setting up a cron job to run the run-periodic-tasks script once per hour. If you are not familiar with setting up cron jobs, please read the following helpful article: Scheduled Postings and Cron Jobs.
...Original article from http://feeds.feedburner.com/~r/LMT/~3/199390845/