WebCron - Pseudo cron scheduler for poor MT users like me
WebCron is a pseudo scheduler for emulating Unix's cron on MT 3.2 platform.
Unix's cron or MS's scheduler enable you to run some tasks on your predefined interval. If you have your own server or buy a premium hosting service, then you can absoluetly enjoy "cron"ing your scheduled tasks. In MT, we can set "Post Status" of an entry to "Scheduled". If you do, publishing of that entry will be postponed until that setting time. As you may predict, this feature needs to use "cron-like-scheduler".
But to poor MT users like ME, these cron-needed-features are "Pie in the sky". Yes it's BIG pie... I even didn't know it's delicious or not because it is in the sky. So I developed this WebCron plugin. It acts like cron. Exactly like cron? Sorry, I already told you it's pseudo cron. But in many case, you'll have no troule in running scheduling tasks. From now on, we can taste pie in the MT.
* It also supports PHP Dynamci Publising.
Scheduled Tasks
In blog system, what tasks can be scheduled? As told you above, MT's "Scheduled" publishing feature is a very good example. What else?
If you use a moblogging tool, you could schedule this task. I made GMoblog Perl script which enables you moblogging by using GMail. You send mail having image or only texts to your GMail account.Then this mail will be published by scheduled publishing task.
And another well-known example is getting your favoriate RSS/ATOM feeds to blog server. You can't use this feature in dynamic publising mode because fetching feeds and customizing it with your tastes are comparatively time-consuming task. So this should be proccessed backgroundly by scheduler.
Installation
Download this plugin and untar it under mt home, then files will be located in sub-folders as below.
- (mt home)/plugins/alogblog/webCron.pl
- (mt home)/plugins/alogblog/webCron.cgi
- (mt home)/php/plugins/function.MTWebCronTrigger.php
Open webCron.cgi, and edit two variables accorging to your environment.
$url_of_this = 'http:/www.example.com/mt/plugins/alogblog/webCron.cgi';
$alogblog_path = '/path/to/your/mt/plugins/alogblog';
Tag Usage
<MTWebCronTrigger> : Add this tag in blog's Main Index template or Individual Entry Archive as you like. More trigger tag you add, better scheduling performance, but more resource-consuming.
Role of this tag : If a visitor request that page which embeds trigger tag, then it triggers webCron.cgi which looks into scheduling-tasks table and if time is up, requests recursively webCron.cgi to run tasks. webCron.cgi acts like normal CGI and normal Perl script which run commands. Easily you can consider it as a normal counter.
If you move webCron.cgi to some other place, then you can tell it by src attribute as like: <MTWebCronTrigger src="http://www.example.com/some/path/to/webCron.cgi" >
Note: You'd better add this tag in the bottom of the page before </body> tag.
Setting scheduling Tasks
Each blogs can have its own scheduling tasks. Go to Weblog Configuration -> Plugins page.

You can add one task per a line. One task line is comprise of two sections. First is interval time. 10( or 10s) means every 10 seconds. 20m is 20 minutes, 30h is every 30 hours, 40d is every 40 days. 0 means no work. You can't set it like "1h 20m". Just one time factor.
Second section is command. This command section require a little attention of PATH. If you have no idea, write a full path.
Default task line is "0 cd /path/to/your/mt/; perl tools/run-periodic-tasks". If you set it to another value, then this task table is written to folder plugins/alogblog/webCron. So if a permission to create this folder and write to task table file, MT will show you error meaasges. If then, you have to make a webCron subfoler and give write-permission to it manually.
Taste a Pie
Follow next steps.
- Install this plugin
- Add <$MTWebCronTrigger$> tag to the most-bottom(before body tag) of Main Index template, and Save and Rebuild.
- Post a test entry, set Post Status to "Scheduled", and set Authored On to near future time(ex. 1 minute from now). Save and goto entry listing page, then you can see that entry's status be "Scheduled".
- Time to set scheduling task table. Go to blog's plugin page, then in WebCron setting, modify interval. Because this is a test and you want to see result ASAP, set interval 10. In every 10 seconds, if a vistor triggers, then scheduled task is run if its predefined time is up. Save Changes.
- Now you act like visitor to your blog. Because we add trigger only to Main Index, open blog home page. If your triggering is done, after 10 plus some time to complete scheduled task(in this case, time to publish all entries having scheduled status), reload entry listing page, then previous entry's staus will be shown as Published, Reopen blog home, then new entry will be shown.
Note
If you want a task to be run on EXACT time you set, and it's of no use to run it after that time, the webCron is not what you want. The only way you can choose is to make much more money and buy your own server or premium hosting service. Only "cron" would make you happy.
But in very very most of cases, especially in blogging system, I think there is no such a delicate task.
Question:
I set to publish some entries in the END of this year, and there is no visitors(= no triggering) for one month since next new year. What if to my scheduled entries, then ?
Answer:
Exactly for one month (by the first visitor comes), your scheduled publishing task will absolutely never be done/published. Oh~ bad webCron!
But I can tell you this. "If there is no visitors for one month, there is of no use to publish entries till visitors come."
License
Released under the Creative Commons License.
Version History
- 3.2.01: for MT 3.2
Comments
I am looking forward to the completion of this plugin. :-)
Posted by: MT4989 | September 9, 2005 06:36 PM
Lee, I tried out the scheduled posting feature a couple of times.
Cool this Plugin.
Please teach me one.
What does "GMoblog" and "Aggregatefeeds" mean?
Thanks,
MT4989.
GMoblog and Aggregatefeeds lines are entered just to show you how to use that config lines. If users have some script tools, multiple tasks can be possible...Ye only for that simple purpose.
GMoblog is a Perl script that enables moblogging using Perl module, Mail::Webmail::Gmail. As you know, GMail doesn't provide any related API. That module only parse GMail's HTML source page. It means it's non-official. During my developing of it, GMail changes source forms a little. If that happens, we have to wait Mail::Webmail::Gmail for updating. So my method is not very good. (Really? ^^) I will open it some days. But who will use it?
Aggregatefeeds are completley fictitious. But I think many related scripts can be found in Internet. In my another deserted blog(alogblog.com/alog), you can see Google/Yahoo Sidebar menu. It is made from old WebCron version. By Google Alerts(by mail) and Yahoo New(by API), webCron gets alerts and news and parse it and save it using ul/li tags on simple javascript file. Then index page(it's static HTML) only have to embed javascript. Because I implemented it by using webCron, even though I haven't posted new entry, Google Alerts/Yahoo News Sidelbar are being updated periodically by some thankful visitors.(It's secret! They dont know they are a trigger. HeHe)
Posted by: MT4989
|
September 9, 2005 09:05 PM
Hi, Lee.
I understood from reading your answer.
"Plugin" that you make is all wonderful.
>In Korean, number 4989 means buying(49) and selling(89).
"4989" is read as "shikuhakku" in Japanese. I have a hard time on MT.:-p
Thanks,
MT4989.
Posted by: MT4989 | September 10, 2005 12:06 AM