How To Make Money With Your Blogs!

BlogForumManagerReportsVideosPluginsDownloadsHelp

Troubleshooting Utopia Cron

by David Pankhurst - July 17, 2008

My Open Source plugin U-Cron makes it easy to time things without setting up a cron job.

But things CAN go wrong - after all, one plugin will not serve the needs of every site out there - there’s too many combinations of versions of PHP, mySQL, WordPress, Operating systems, hardware, (and so on and so on)…

So here’s a bit of a checklist on what to check out:

  • U-Cron requires your theme to cooperate. At the bottom of most themes today is a function call wp_footer() - if this is missing, U-Cron is NOT called. Switch to the default theme - if the problem goes away, you have a naughty theme.
  • U-Cron needs visitors. Because it works with your theme, if there are no blog page views, U-Cron doesn’t run. You need visitors!
  • U-Cron needs calls. Some software caches web pages. This takes a snapshot of the HTML and replays that instead of calling the PHP code again and again. You get more speed - but U-Cron is NOT called, just as if you had few visitors. Turn it off, or make it refresh the cache frequently (say every hour or so).
  • U-Cron needs certain security settings. Basically, though, if you can see all the info in your WP dashboard, U-Cron should work - if you can’t, it won’t.
  • U-Cron is not exact. This is deliberate, to prevent collisions (multiple visitors setting off the same cron job). If you need exact to the minute timing, then you should go with the system cron.

So to get it running, you need to test - how?

Enter a KNOWN GOOD setting. If you have a URL you can monitor, enter that. If not, use this code:

<php
//
// utopia cron tester
// to use:
// 1) edit email, password only:
$u38_password='change-this-password';
$u38_email='someone@abc.com';
// 2) place this file on your blog's site
// 3) call manually (via browser) to make sure it emails
// format: http://egwebsite.com/mytest.php?p=yourpassword
// 4) using SAME URL, enter into u-cron
// 5) set to reaosnable timing (say every five minutes to start)
// 6) turn off/delete when you've seen enough emails!
if ($u38_password!=trim($_GET['p']))
  exit("bad/no pwd!");
$flag=mail($u38_email,
  "Cron Job Test",
  "You sent an email from your site via '"
   .basename(__FILE__)."' on ".date('r')."\r\n",
  "From: webmaster@{$_SERVER['SERVER_NAME']}\r\n");
echo $flag?"cron info mailed":"NO MAILING";
?>

Edit, save as a file, and place on your blog’s site, then call it to send you a status email. For example, if your your password is ‘abcdef’, and you’ve called the file ‘tester.php’ on egwebste.com, it would look like this:

http://egwebsite.com/tester.php?p= abcdef

You’ll get a message and an email sent (or an error and none sent).

From there, use THAT EXACT URL for your cron job, call it every five minutes, then extend once the emails start coming in.

Also, you can use Test and View. Test calls the URL like U-Cron does, but without a timer. If it comes back AOK, then you should be OK. If not, that will need to be corrected first. View simply shows you the page - NOT the same as test, just a helper to show what the page looks like.

At this point, you either have emails coming in (or another URL being called that you can verify) - or you don’t. If this works, then you are good to go!

Once you’re satisfied it works, delete the file and U-Cron entry (also remember to place the file on ANOTHER website to make sure you can call external files, not just ones on your site).

One more note - I cannot troubleshoot other people’s scripts - if you get to this point and you’re getting emails, then you are calling scripts properly - consult the other script’s guide for their requirements.


ActiveBlogging.com - for information on making your blog successful! Get information like this - and more - inside! Details here or Join Today!

Leave a Reply