Scheduled Postings and Cron Jobs
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. Instructions for both are discussed here.
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 isFor 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. Advanced 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.
- Log into your server.
- Get into your crontab editor
- 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:
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.
Copyright © 2004 Elise Bauer and Arvind Satyanarayan.