How to Time Things in WordPress – Cron Job Plugin
I was reading a comment online about the difficulty of doing Cron jobs. Cron jobs currently make sure *NIX programs run on time. Execution of programs – a complicated topic for a simple thing like scheduling events.
The problem is Cron – it’s a powerful program, and a lot of times all you want to do is run something approximately every 15 minutes, once a day, etc.
As well, some web hosts prevent cron jobs.
What’s a WordPress blogger to do?
So I sat down and wrote very simple plug-in. What you do is enter in a series of URLs, and a time. It then checks them by loading in the webpage or PHP code (or whatever the URL points to]), and you end up triggering whatever code is on that page.
You can download the WordPress cron plugin (Utopia Cron) here.
Installation is simple: download, unzip the utopia38.php file, upload it and activate. Go to Manage/U-Cron and enter the URL and timing info of the page(s) that you want loaded.
Then, as your blog pages are loaded, the program will visit each URL you entered in turn. Depending on what the page does, it may activate something, or just load.
- For example the free banner ad program phpAdsNew/OpenAds requires the page maintenance.php to be loaded every hour – you would enter the full URL of the page on your system, specify a start time, and then a frequency of 1h – if the start time is 00:20, then you would check approximately at 00:20, 01:20, 02:20, etc.
- Another example is WordPress blogging by email – you can set up your email account in the Options/Writing/Post subtab, but you need to load/view the wp-mail.php file to actually check for posts. Use this to check every few minutes, and emails will get posted easily (and you’re also avoid tying up resources by checking TOO often).
Note: after you enter a URL, test the page to make sure it loads properly, and view it to make sure you’re loading the right page. On WordPress blogs, if the page is wrong, you might get a 404 page, which is NOT an error from the plugin’s point of view.
So, give it a try see if it helps with your timed jobbies.
(Update: I’ve discussed troubleshooting in more detail in this post).









I have installed it, and it works when i trigger it manually, but it doesn´t schedule and work with timers set…. what´s the trick?
Rune
One possibility is you’re using an old theme – it needs wp_footer() in the footer.php file (or anywhere near the bottom) to run.
Hello again, and thanks for your answer.
The thing is, I use WP-O-Metic, and have added some rss feeds to the list of campaigns.
As you probably know, there is a “fetch” link to the campaigns. Running the fetch from here, works smoothly. Copying that link to the ucron, doesn´t help much. If I hit the “view page” link in ucron, the fetching is performed. But the “schedule”, does not seem to work. I have set the settings to “10m”, with the start time at 00:00. I am trying to load the webpage (enduser) several times, but nothing happens.
I have checked the template, which is the Revolution Blog Template, which do include the footer.
Any ideas?
I tested it here, and the two work together fine. Some thoughts:
1) the feed plugin requires a security code included as part of the url – without it, it will fail.
2) cron is an ‘approximate’ timer – it can vary by as much as four minutes from the expected time.
3) blog page loads are used to time the cron plugin – if you get few visitors, the timer will be sluggish (eg if you time something every hour, and no one visitors in three hours, only the last hourly call will work).
4) not every site allows page loading in PHP – if your WP dashboard doesn’t load for instance, then this plugin won’t work, either.
You can use the test buttons in the cron job to see if everything is working/loading.
The dashboard loads. No problem. Can it be that my ISP does not provide support for cronjob or curl()?
This plugin means you don’t need cronjobs, so that isn’t an issue, and if the dashboard loads, then this plugin should work (it uses similar code). Try the ‘test’ button – this will let you test it without waiting for the timer to count down, and will give you an error message if it fails for any reason. If it succeeds, then the problem must be with the other plugin.
As pointed out earlier, – the testbutton works. I cant understand what this is. Everything seems to be working nicely, besides the pure scheduling of it…
This is what I have one:
1. Created a campaign in wp-o-metic. Tested it. It fetches and posts are created. I copy the link behind the FETCH link.
2. I enter u-cron, create a entry, start time 00:10, check every 10m, the url i copied are pasted in the url field. I save it. Test is ok. If I click “view page”, it fetches, and posts are created.
3. But, nothing happens on a schedule….
Addtional info:
I have now even added a external URL to the cronjobs in ucron, to a server which I have access to all posts/gets requests on the webserver. NONE are performend from the installation of u-cron (scheduled). If I hit the test/preview buttons, then the request is logged.
So the problem is not only within Wordpress, but the cronjob itself. It does not process.
Comments?
Rune
I am sorry to spam you like this, but looking more into it, – ucron DOES hit the external url on a scheduled basis.
Then the problem is, why doesn´t it hit the internal one? Am I using the correct url? (i guess i am, since it works manually).
Can the answer be this easy: Wordpress Ucron plugin runs on a “anonymous” mode, which probably wont work pretty well in combination with wp-o-metic? Which performs a post to the blog?
Rune
Since the test button works, you are doing the same code as the timer does, with the exception of the timing itself.
So the question is, what interferes with the timing?
1) Not enough visitors. Manually refresh the page every five minutes or so. If that solves it, you’ll need a cron job after all (the code is visitor-driven).
2) Caching pages. Turn off caching – with caching the theme is not called, it’s displayed – so wp-footer isn’t called, and no processing.
3) Bad theme. Use the default theme to check – if it works, you’re theme is the problem.
4) Not using full URL – even if it’s local, it needs to be http://egwebsite.com etc…
You need to divide and conquer – I’ve created a test script you can use to email yourself results at http://ActiveBlogging.com/info/troubleshooting-utopia-cron/
2: How can i turn off caching? in a ISP environment? is it a application setting in WP or serversetting for ISP?
The caching would be an addon plugin like wp-cache or supercache – if they are on, turn them off to see if the problem goes away – also, in the other post I mentioned I included an email script to test – give it a try, follow the steps I mentioned, and try to isolate where the problem is occurring.
After upgrading to WP 2.7 there is no longer a Manage tab in the WP Dashboard (It’s replaced by Settings) and U-CRON is not listed under Settings.
U-CRON still shows up in Plugins and is active and seems to be working but there is no longer any way to configure it.
WP 2.7 changes the menu layout significantly – the U-Cron tab is now in the ‘Posts’ section, at the bottom.
Hey,
Another (simpler) solution to this problem is the service I created: Cronless.com. You get a free online cron job with your account sign-up and it’s perfect for bloggers. Use it to automate posting. Much easier to use/configure than the WP-Cron plugin.
Hope that helps!
-Dave
>>Much easier to use/configure than the WP-Cron plugin
Using Utopia Cron is pretty simple – activate, and add URLs in the Admin page. I haven’t worked with WP-Cron however, so I can’t compare how easy that is. Also, Utopia Cron allows unlimited URLs entered – your site allows a small number (around 5?) before subscribers have to upgrade to the (paid) premium service.
Hi,
I installed your plugin to run a wordpress page every hour.
But my page is published as private and I think that the cron doesn’t execute properly.
Is there a way to it work as if I was logged in?
thx
Unfortunately, no – the plugin runs a URL every time, and so you need to include the password in the URL (GET variables instead of POST ones). However, a quick test showed that adding “?password_post=xxx” (with a valid pwd) to the line did not give WP the password – so it only works with the password form, so you can’t do it this way.
Be sure to use the plugin’s test button to see how the program reads the URL – this may give you a workaround or clues as to what is not running right. Don’t forget, once you log into a password-protected page, the password is reused until you close the browser or ‘forget’ your cookies.
It looks like this plugin can do pretty much what i want, but im not sure which link (or file) should i call?
im using a rss feed widget (image feed widget) and i want basically to updates the feeds every 3hours.
Apparently wordpress is doing it once a day, but i need some more often refresh
Would love some help on that
Thanks
Anything you have the plugin call needs to be in the form of a URL (with http:// in front). If you can’t do it (or for example it needs a password or cookie value you can’t pass as part of the URL) then it it won’t work.
David,
Thanks for your answer and I totally understood that,
But the question is what URL should i call to have wordpress refreshing the cron ? (or refreshing the front page)
its not a password protected page neither a cookie value.
I just want to the feeds (coming from the plugin) refreshing every 3hours.
Thanks
Unfortunately, it depends on the code you’re using – check its documentation for something like a polling URL or URL to call to process the feeds. And confirm that the plugin can be run more frequently – if a plugin has a URL you can call but refuses to refresh every 3 hours, calling it more often won’t make a difference.
Hey David,
First of all thx for your nice plugin. it’s very helpful since not each webhoster offers the possibility of setting up cron jobs manually.
but there is a small bug in your plugin according to the latest wordpress version:
No Navigation in the backend menu is displayed. So simply remove the line 351:
add_submenu_page('edit.php','U-Cron','U-Cron',9,'u38_menu','utopia38_menu');
with this one:
add_submenu_page('tools.php','U-Cron','U-Cron',9,'u38_menu','utopia38_menu');
have a nice day!
Thanks for the update – while not exactly a bug (the UCron entry is found under the ‘Posts’ links rather than the ‘Settings’ tab), it’s due to the way WP has changed from version to version. The next version of UCron will fix this – unless WP changes things again…
Leave your response!
What IS ActiveBlogging?
Click here for more details
Great Deals On WordPress Plugins!
• Easy Ad Blocks Plugin - Click Here.
• Easy Blog Popups Plugin - Click Here.
• Fading Ads Plugin - Click Here.
• Easy AutoPoster Plugin - Click Here.
• Easy Affiliate Links - Click Here.
• Easy 'TinyURL' Links Plugin - Click Here.
• Automatic Comment Killer - Click Here.
• Easy Social Rankings Plugin - Click Here.
• Easy Split Tester - Click Here.
Latest Issue
Categories
Other Sites
Pages
Archives
Special Offers
Click Here for details.
Recent Posts
Most Commented
Recent Comments