September 24, 2004
Scheduled Postings and Cron Jobs
Co-authored by Elise Bauer and Arvind Satyanarayan.
Tutorial cross posted on Movalog and Learning Movable Type
Future posting is a convenient new feature in MT3.1x, allowing you to create an entry and have it automatically post at a future time. But before you can use this feature you need to set up a Cron Job on your server.
What is a Cron Job?
Cron is a task scheduler for unix servers. A cron job is a specific task that runs a certain number of times per minute, day, week, or month on your server. For example, you can use a cron job to automate a daily MySQL database backup. The main problem with cron jobs is that if they aren't properly configured they can cause high server loads which may result in suspension of your site with your web host. If you are able, configure your cron job so that the results of running the scheduled script are emailed to you.
There are two main ways by which you create a cron job on your server: cPanel, and using shell access to your server. Cpanel is the easiest way; shell access requires knowledge of UNIX editing commands and should only be attempted by those familiar with such commands.
If your webhost has cPanel installed, search for the cron command in cPanel. You may be presented with a page where you select your experience level - standard or advanced. Presented are instructions for both.
Using the standard function in cPanel, the cron job editing screen should look something like this:
Your email needs to go in the textbox at the top of the screen so that the results of running the script are emailed to you. The command to be run is
Substitute <path to mt> with the path to your MT cgi files.
For example, if your MT installation is in your cgi bin, it might look like this:
If your MT installation is in your public_html directory, it could look like this:
It should be set to run every 15 minutes of every hour, every day, every weekday and every month.
Using the Advanced function in cPanel, you will be presented with a different screen. Fill it out as shown below:
Substitute "arvinds" with your email at the top. The cron should be set to run
*/15 * * * * (every fifteen minutes of every hour of every day, every weekday, every month). The command to be run is
Using Shell Access
The Shell Access method is explained in the MT Manual. At the time of this writing, although the steps outlined in the manual are correct, the crontab command is not.
1. Log into your server.
2. Get into your crontab editor
3. Add the following command:
Where your path to mt is your specific path to your MT files.
This command instructs cron to run the script every 15 minutes of every hour of every day. Make sure this command is exactly as written.
There have been many errors experienced during setting this up. The first being an MT.pm error. At the time of writing this tutorial, the documentation was incorrect as the command to be run was not correct. Make sure you use the command to run as shown in this tutorial.
If you get a permission denied error make sure the run-periodic-tasks script has 755 permissions (the same permissions as all the cgi files)
If you get the error message:
You have scheduled posts but have not entered a Remote Services username in your profile, or you don't have a Movable Type proof-of-purchase. You need to do so before scheduled posts will be released.This is a weird bug in MT at the moment. This error message does not affect anything. You can ignore it.
With the cron job set up you are now ready to schedule your weblog posts. On the Edit Entry page of the entry that you would like to schedule for a future posting, scroll down to the bottom of the page to where you see "Post Status".
You can now select "draft", "publish", or "future". Select "future" and adjust the date and time for the date and time that you want the post published.
MTTrickle - automated posting of deferred MT Entries, for MT2.x
MT-Publish-On - Tim Appnel's code modification patches for MT2.64 to allow future posting.
ScriptyGoddess's Pre-Post script
Has this tutorial been helpful? Please consider linking to Learning Movable Type at http://learningmovabletype.com/ . Thanks!
If you would like to send a trackback
please use the following URL: http://learningmovabletype.com/cgi-bin/mt32/mt-tb.cgi/348
This will probably not be news to most other bloggers out there using MoveableType 3.x, but it took me a while to figure it out so I'm posting it here in the hopes that I can help someone else stuck......[read more]
Tracked: March 13, 2005 07:43 PM» Nice Blog For Learning Movable Type from Willie Crawford's Marketing Insights
There's a nice blog at: http://www.elise.com/mt/ where a lot of Movable Type how to is explained. For example, there's an......[read more]
Tracked: May 19, 2005 10:22 PM» Cron Jobs and MT from Much Madness is Divinest Sense
Learning Movable Type has an interesting post about scheduled postings and cron jobs. A cron job is an automated task set to run in the future. If you have MT 3.x, you have probably noticed you can save a post......[read more]
Tracked: July 7, 2005 08:00 AM