Jump to content
cosmicsafari

LazyCron Stops Firing

Recommended Posts

Hi all,

I have noticed that LazyCorn seems to run maybe once or twice and then just stops.

Has anybody else encountered this, I have the following within 2 different modules.

public function init(){
    $this->addHookAfter('ProcessModule::executeEdit', $this, 'configurableButtons');
    wire()->addHook('LazyCron::every15Minutes', $this, 'autoGenerate');
}
public function init(){
    wire('forms')->addHookAfter('ProcessModule::executeEdit', $this, 'configurableButtons');
    wire()->addHook('LazyCron::everyHour', $this, 'getExport');
}

Does having multiple LazyCrons setup cause any issues?

Share this post


Link to post
Share on other sites

LazyCron is driven by user visits. Are you sure the site is being visited regularly? If you need to guarantee a run, you need to setup a cron job to visit a page on your site, or simply use cron itself to drive your tasks. Another possibility is that the cron script is timing out behind the scenes and leaving the LC script jammed.

  • Like 1

Share this post


Link to post
Share on other sites
31 minutes ago, netcarver said:

LazyCron is driven by user visits. Are you sure the site is being visited regularly? If you need to guarantee a run, you need to setup a cron job to visit a page on your site, or simply use cron itself to drive your tasks. Another possibility is that the cron script is timing out behind the scenes and leaving the LC script jammed.

The site has a regular flow of visitors so I don't suspect it is that, the timing out issue could be possible right enough.

What would be the best way to un-jam it if thats the issue? Uninstall/Reinstall LazyCron?

Share this post


Link to post
Share on other sites

Hi @cosmicsafari

Just look in the cache directory for a file called LazyCronLock.cache. If it is there for more than half a minute (or however long you estimate your code should run for) then delete it to unjam LazyCron. If this keeps happening, then there could be something in your hook method that is timing out and leaving the lock file there.

Here's some code to return the location of the file if you want to do it programmatically...

function getLazyCronLockfileName() {
    return wire('config')->paths->cache . "LazyCronLock.cache";
}

 

  • Like 8

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By fruid
      Hi friends,
      just 7 months ago, I was "just" a designer and a rather semi-developer, still struggling with WordPress sites and more often than not delegating that work to pros. ProcessWire really helped me realising that it's not that hard after all (well it's still hard but it's doable) and you learn a lot just by doing it which has to be true for all developers anyway. So I started coding myself, I might also have to thank the 2020 pandemic to help me focus a bit more than usual, I created a bunch of websites using PW already – one of which I can't wait to put on showcases but it's still not live yet. That is one big personal milestone for me. The next milestone would be to give something back, and so I'd like to take on contributing some code I wrote, namely a event calendar for anyone to use. It's my first attempt doing this so please don't eat me alive. It's not a PW module yet (that's the plan however) just a git but I'm positive it will be useful once it works – well it works but it still needs more work – because if I had found a module that came close I wouldn't have started coding it myself :D
      With that, I will appreciate all input, be it how to improve the .js (probably especially), or the templates, or guidance how to proceed turning this into a PW-module, and of course, in that last process, no pun intended, suggestions to make it more versatile for different needs.
      git: github.com/bbblgmsp/ProcessEventCalendar
      demo: http://foobar.roofaccess.org/events/
      Thank you!
    • By snobjorn
      I'd like to set up a LazyCron function that fires every hour on each page that has a template named "post". So far I have gotten the function running. But when it has fired once on "Page with Title A", it takes and hour before it is fired again on any other pages. It makes sense, hooking the function with wire()->addHook().
      What I want to do, is to get the function to be fired with LazyCron individually for each page. So that "Page with Title A" fires every hour (if it has pageviews), and "Page with Title B" is fired individually and possibly during the same timeline, if it has pageviews.
      Is this possible? Or might there be another way to utilize a sort of LazyCron on individual pages?
    • By MarkE
      LazyCron operates on an elapsed time interval, but you may want it to operate at specified times.
      Assuming your website is going to be visited sufficiently frequently (either by real users or by a Cron job), you can do this by editing the file /assets/cache/LazyCron.cache. This file contains 21 timestamps – one for each of the LazyCron specified intervals (e.g. “everyMinute”). The timestamp denotes when that interval was last triggered. To make the trigger happen at the required time, change the timestamp in the matching row to be when the previous trigger should have occurred.
      To make this easier, I have done an Excel spreadsheet (“Lazycron_fill.xlsx”) to simplify the process – just enter the required benchmark timings and copy the result into the LazyCron.cache file.
      Lazycron_fill.xlsx
    • By Lmwt
      Hi there,
      I am new to PW but already very convinced. I need to build a dropdown button to browse in a collection of authors by country and language. The dropdown should be editable in the BACK and displayed on the same as the authors collection. I tried my luck with "PageField Creator" but I don't know how to display the dropdown, I simply used: 
      "$content .=$page->Land;" (the name of the select field)
      but nothing is displayed...
      I see there is a 2nd module out there to achieve this : "Select Options Fieldtype". I am not sure what is the difference, anyone has a tip?
      And a clear tutorial with the necessary steps to build this? I am a bit confused which should be the parent template or page, if it should have a file or not...
      Thanks a lot in advance!
×
×
  • Create New...