ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Cron plugin weirdness

August 05, 2008 9:42am

Subscribe [2]
  • #1 / Aug 05, 2008 9:42am

    Luke Stevens

    80 posts

    Hey guys, I might be missing something really obvious here, but I’m getting some strange results with the cron plugin. In an empty test template, I have:

    {exp:cron minute="*" hour="*" day="*" month="*" } 
    
    some content
    
    {/exp:cron}

    AFAIK that should appear every time the template loads. However, no matter what values I give the plugin date/time params (right or wrong, or as above), “some content” will appear on the first page load, but then not appear on subsequent refreshes. Caching is off for the template, and I’m kind of at a lost as to what is going on, or maybe I’m missing something obvious! I’m using the latest version of the cron plugin (1.0.3) and EE 1.6.3 (yeah yeah.. 😊.

    Any help would be much appreciated 😊

  • #2 / Aug 05, 2008 10:05am

    Robin Sowell

    13255 posts

    Before I start testing- is it just the first page load.  And then when you go back to it later, it obeys the time settings?  If so, I’d think that’s expected behavior.

    (vs every time you first go it shows, but doesn’t on refreshes.)

  • #3 / Aug 05, 2008 10:35am

    Luke Stevens

    80 posts

    Thanks Robin, I’m about to head off here, but this is what happens:

    1. First load - content appears (regardless of whether it should or shouldn’t according to the time params, and I’m comparing with {current_time} )
    2. Refresh - doesn’t appear… *refresh* *refresh* *refresh* still doesn’t appear any of those times (though it should I think with correct time settings, or * * * * as above)
    3. Save the template with slightly different plugin settings (right or wrong, it doesn’t matter).
    4. See 1. 😊

    So it doesn’t appear to be obeying the time settings either way, it just shows up on the first load, then disappears for subsequent refreshes until you alter the plugin settings slightly, then it appears for the first load, disappears after that… weird! 😊

  • #4 / Aug 05, 2008 10:53am

    Robin Sowell

    13255 posts

    I believe the first time it has to load- to set the baseline time ‘now’ for comparison.  Could be wrong, but I don’t think so.  Then should basically obey the time settings after that- assuming the page is being loaded with regularity.  You set it to 5 minutes and don’t load the page for 10 minutes, the chron will never trigger.  Until you load the page.

    But yep- let me go set one up.  Will let you know how it goes for me.

  • #5 / Aug 05, 2008 8:14pm

    Luke Stevens

    80 posts

    Any luck Robin? 😊

  • #6 / Aug 05, 2008 8:54pm

    Sue Crocker

    26054 posts

    Hi, Luke. Robin works the early shift.. she should be back on in about 12 hours or so.

  • #7 / Aug 07, 2008 8:05am

    Luke Stevens

    80 posts

    No probs, don’t want to be a pain but maybe Robin will catch this next shift 😊

  • #8 / Aug 07, 2008 10:54am

    Robin Sowell

    13255 posts

    Luke- I’m just not seeing anything wrong with the plugin.  I used your example- which should trigger every minute.  The very first page load, it writes a file to system/cache/cron- only thing in there is a uct time: 1218116642.  Every page load after that, it compares current time to the cached time- if current is more than 60 seconds out from the time cached, it displays the data and writes the new time to cache.

    Granted- I wasn’t timing it to the second on my refreshes.  But it seemed to work just fine.  How’s it working for you in a way that seems ‘off’- cause from what I can see, it’s doing what it’s meant to.

  • #9 / Aug 07, 2008 12:54pm

    Luke Stevens

    80 posts

    Ahhhhh I see I see, you’re right, thanks for taking a look 😊 I misunderstood from the example in the docs, assuming * for minutes was the equivalent of it being true for any time within the other parameters (hours & days etc), so 00:01:00 (hh:mm:ss) would be true, as would 00:02:34 or 00:59:59 or whatever, & would show the appropriate content. But of course it’s evaluating for *one* instance every minute, as opposed to being on for any part of any minute, if that makes sense. Well, it does to me now, so I’ll need to think a bit harder about what I want to achieve.. thanks again! 😊

  • #10 / Aug 07, 2008 1:05pm

    Robin Sowell

    13255 posts

    LOL- well now you’re hurt my brain.  But yep- I think you get it now.  It’s really just checking for ‘x’ number of seconds past whenever the cached time is- if expired, run and update cache.  Hm- though yea, I see why it could be confusing for like ‘first hour of first day of the month’- logic is a bit different.  Were you expecting it to run at say one o’clock and 01:00, 02:00, 03:00 after the hour - so like, if the first time, the cache is set to the equivalent of 01:20, it would ‘trigger’ 40 seconds later?  Hm- you might be right.  (Perhaps minutes were not the best way to test this.)

    Bugger- now I’m all confused.  Want me to ask Derek?

  • #11 / Aug 07, 2008 1:16pm

    Luke Stevens

    80 posts

    Haha nah it’s cool, I just didn’t pay enough attention to the docs (or stop to consider that it’s cron after all, duh), ie it says

    {exp:cron minute="*" hour="*" day="1,15,31" month="*"}

    Displays this content once every minute of every hour on the 1st, 15th, and 31st day of every month

    {/exp:cron}

    What I hoped was that it would display that content for the *whole* minute, of every minute, of every hour etc… rather than the (totally normal) behaviour of displaying it once *on* the minute, every hour etc, which ain’t particularly useful in my situation (or to display content in general I think, but obviously cron’s for executing something at particular intervals).

    Anyway it’s late here so I’ll have a think about it and post something in How To if I get stuck, cheers 😊

  • #12 / Aug 07, 2008 1:29pm

    Robin Sowell

    13255 posts

    Ah- got it.  And will thus close her out.  😉

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases