Problem with php cron job

16 posts by 2 authors in: Forums > CMS Builder
Last Post: August 6, 2014   (RSS)

  • Archived  

By Dave - July 29, 2014

Hi nmsinc, 

Check for and remove any whitespace before the first <?php tag.  Output started in line 0 usually means there was something that got sent on line 0, usually spaces or enters.

And failing that, check none of the plugins you're loading have extra whitespace at the top or bottom (disabling a plugin is a quick way to check, if you don't get an error after disabling the plugin then it's that plugin).

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com
  • Archived  

By nmsinc - July 30, 2014 - edited: July 30, 2014

Hi Dave,

I deactivated each plugin one at a time and allowed the cron job to run. I also made sure that the white spaces on the first and last lines of the cron job were removed and results were the same.

Also, if I remove the following three lines of text then I get a record access error!

  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/home/claimsca/public_html/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}

Any other suggestions?

Thanks - nmsinc

nmsinc
  • Archived  

By Dave - July 30, 2014

Hi nmsinc, 

Could you email CMS/FTP login details over to dave@interactivetools.com (email, do not post login details to the forum), as well as a link to this post and the page in question on your site? I can take a quick look for you and let you know what the problem is. 

Thanks!

Dave Edis - Senior Developer
interactivetools.com
  • Archived  

By nmsinc - August 5, 2014

Hi Dave,

I sent you two emails last week regarding this and no answer - do you have any ideas?

Thanks - nmsinc

nmsinc
  • Archived  

By Dave - August 5, 2014

Hi nmsinc, 

Sorry, looks like these got flagged as spam as a false positive (Google Apps Email).  I'll check this out now, thanks for letting me know you didn't get a response!

Dave Edis - Senior Developer
interactivetools.com
  • Archived  

By Dave - August 5, 2014

I responded via email.  Can you post back here when you respond just so I can ensure I get it?  Thanks!

Dave Edis - Senior Developer
interactivetools.com
  • Archived  

By nmsinc - August 5, 2014

Hi Dave,

I just responded!

nmsinc
  • Archived  

By Dave - August 5, 2014

Thanks, it looks like email is getting through now.

The issue was this line:

<?php if (!$CURRENT_USER) { websiteLogin_redirectToLogin(); } ?>

The website login system uses cookies, and when the script is being run from the shell there's no browser or cookies, so you're getting errors related to the login system trying to set cookies.

I replaced that with this line and it now works correctly: 

if (!inCLI()) { die("This script can only be run via the command-line or cronjob."); }   

The inCLI() function returns true if the script is being run from the shell/command-line.  

If you wanted it to run from the shell without requiring a login, and/or run from the web if the user is logged in, you could try something like this:

if (!inCLI() && !$CURRENT_USER) { websiteLogin_redirectToLogin(); }

And for new cron jobs, you might check out the new built-in cronjob system here: /cmsAdmin/admin.php?menu=admin&action=general#background-tasks And the example plugin "Cron Example" under "Plugins".  The new system logs cron output, catches errors, emails admins, makes it easy to manually launch cron tasks from the plugin menu, etc.   I wouldn't bother upgrading to it just yet, but next time you need to adjust a cronjob or write a new one it might be worth a look.  

Hope that helps!  Cheers.

Dave Edis - Senior Developer
interactivetools.com
  • Archived  

By nmsinc - August 5, 2014

Thanks Dave I appreciate your help with this!

nmsinc

nmsinc