1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

Scheduler Cron Not Processing Script

Discussion in 'Community' started by SoilentRed, Dec 3, 2019 at 10:51 PM.

  1. SoilentRed

    SoilentRed Caaan do!

    Level: Community
    I have a scheduled task published. When I tick the task and click run, the script processes and executes properly. I have the script running every 5 minutes.

    I see the timestamp on "Last Run" updating every 5 minutes, but the script does not seem to be processing. This script sends out Text messages that are scheduled, but the texts that are scheduled are only being sent when I tick the box and click run. not automagically in the background. how do I diagnose this?

    Thanks for everything yall.
     
  2. troester

    troester Well-Known Member Staff Member

    Level: Community
    Maybe an access issue. If triggered by frontend activity it's running (usually, if not logged in) with public access.
     
  3. SoilentRed

    SoilentRed Caaan do!

    Level: Community
    Oh boy.
    So, I have two templates on my site. one is for the pubic. the other is for logged-in, registered users. The public template contains a series of redirects in the header of my template that land a logged-in user in their respective group page. Here is a sample of the protocol that illustrates what is happening:

    Code (Text):

    <?php
    header("Cache-Control: no-transform");
    $app = JFactory::getApplication();
    $user = JFactory::getUser();
    $groups = $user->get( 'groups' );
    if ( $user->get( 'guest', 0 ) ) {
    }     else if ( in_array( 17, $groups ) )  {
        $app->redirect( JRoute::_( "index.php/my-groups" ) );
    }     else if ( in_array( 196, $groups ) ) {
        $app->redirect( JRoute::_( "index.php/repman" ) );
    }     else if ( in_array( 252, $groups ) ) {
        $app->redirect( JRoute::_( "index.php/groups/viewgroup/99-tx-achievers" ) );
    }     else if ( in_array( 250, $groups ) ) {
        $app->redirect( JRoute::_( "index.php/groups/viewgroup/98-pa-delaware-valley" ) ); // There's a whole bunch more of these....
    }     else {
        $app->redirect( JRoute::_( "index.php/my-groups" ) );
    }
    ?>
     
    I haven't gotten around to making this better.

    Anywho, When I open a private browser and run the fabrik cron url https://www.whatever.com/index.php?fabrik_cron=1, I see the page refresh. This is odd, because if I run any of my other cron urls, like https://www.whatever.com/index.php?option=com_acymailing&ctrl=cron I recieve a report that the cron was triggered. SO, I threw a vardump at the end of the script to see if I can get anything by running https://www.whatever.com/index.php?fabrik_cron=1. Nothing. The page still refreshes. BUT, when I logged in, I got a page that displays the vardump. So, yes, I agree there's a permission issue at work somewhere. But I don't knwo why is would trigger the cron on pages that have nothing to do with executing the tasks... This behavior seems unique to fabrik as my other cron urls are not doing this. Any thoughts?

    Thank you!
     
  4. SoilentRed

    SoilentRed Caaan do!

    Level: Community
    I'm a mess.
    That behavior seems to be a caching issue now. I cleared the site cache, ran the url and I got the vardump. However, It only showed that one time. Then it started redirecting me to the front page again. Again, this is unique to the fabrik cron as my other cronjobs consistently fire off their confirmation every time.
     
  5. troester

    troester Well-Known Member Staff Member

    Level: Community
    Is this a php cron plugin with a list selected?
    I didn't test but I think if the list has no rows visible to public (ie, no access at all or a prefilter) it will "run" the cron but it won't execute the script (because there's no row data).
     
  6. SoilentRed

    SoilentRed Caaan do!

    Level: Community
    Actually, no. But I just tested it both ways and it is still behaving the same way. Tested after performing a supercacher flush on cpanel and clearing my cache stuff in jotcache.

    same behavior.
     
  7. SoilentRed

    SoilentRed Caaan do!

    Level: Community
    Mercifully, a solution has been reached.

    See, what had happened wuz...

    There was an issue with the time zone. I was not converting the times to for my time zone (CONVERT_TZ). What added to the confusion was that when I would manually fire off the cron task by ticking the box and clicking "Run", the task would execute with the time I presumed was correct. This lead me to believe that the cron was not running unless manually triggered. I think what was actually happening was all the test I tried were inadvertently scheduled several hours behind. I'm still clear as mud on how the test would work when I manually ran the cron...

    Anywho last question:

    I have people in different timezones who will be getting down on this. Does that mean I need to adjust the timezone to their locality? It so happens that I am in the same timezone as my server...
    What I had to enter for my event to trigger as expected was
    Code (Text):

    $scheduledDateTime = $formModel->getElementData('sms___scheduled_datetime');
    $scheduledDateTime = new DateTime($scheduledDateTime);
    $scheduled = 'CONVERT_TZ(' . $myDb->quote($scheduledDateTime->format('Y-m-d H:i:s')) . ', "+0:00", "+6:00")';
     
    So, does this mean that for my california users, they will have to use
    Code (Text):

    $scheduledDateTime = $formModel->getElementData('sms___scheduled_datetime');
    $scheduledDateTime = new DateTime($scheduledDateTime);
    $scheduled = 'CONVERT_TZ(' . $myDb->quote($scheduledDateTime->format('Y-m-d H:i:s')) . ', "+0:00", "+8:00")';
     
    And my east coast users will need to run
    Code (Text):

    $scheduledDateTime = $formModel->getElementData('sms___scheduled_datetime');
    $scheduledDateTime = new DateTime($scheduledDateTime);
    $scheduled = 'CONVERT_TZ(' . $myDb->quote($scheduledDateTime->format('Y-m-d H:i:s')) . ', "+0:00", "+5:00")';
     
    ??
    Thank you for your help today.
     

Share This Page