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.
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).