LazyCron class

Provides hooks that are automatically executed at various intervals.

===========================

It is called 'lazy' because it's triggered by a pageview, so it's accuracy executing at specific times will depend upon how may pageviews your site gets. So when a specified time is triggered, it's guaranteed to have been that length of time OR longer. This is fine for most cases. But here's how you make it NOT lazy:

Setup a real CRON job to pull a page from your site once per minute. Here is an example of a command that you could schedule to execute once per minute:

wget --quiet --no-cache -O - http://www.your-site.com > /dev/null

USAGE IN YOUR MODULES:

In your own module or template, add the function you want executed: public function myFunc(HookEvent $e) { echo "30 Minutes have passed!"; }

Then add the hook to it in your module's init() function: $this->addHook('LazyCron::every30Minutes', $this, 'myFunc');

PROCEDURAL USAGE (i.e. in templates):

create your hook function function myHook(HookEvent $e) { echo "30 Minutes have passed!"; }

add a hook to it: $wire->addHook('LazyCron::every30Minutes', null, 'myFunc');

FUNCTIONS YOU CAN HOOK:

every30Seconds everyMinute every2Minutes every3Minutes every4Minutes every5Minutes every10Minutes every15Minutes every30Minutes every45Minutes everyHour every2Hours every4Hours every6Hours every12Hours everyDay every2Days every4Days everyWeek every2Weeks every4Weeks


Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the LazyCron class also inherits all the methods and properties of: WireData and Wire.

Show class?     Show args?       Only hookable?    

Common

NameReturnSummary 
LazyCron::afterPageView(HookEvent $e)
NoneFunction triggered after every page view. 
LazyCron::every10Minutes($seconds)
None
LazyCron::every12Hours($seconds)
None
LazyCron::every15Minutes($seconds)
None
LazyCron::every2Days($seconds)
None
LazyCron::every2Hours($seconds)
None
LazyCron::every2Minutes($seconds)
None
LazyCron::every2Weeks($seconds)
None
LazyCron::every30Minutes($seconds)
None
LazyCron::every30Seconds(int $seconds)
NoneOne or more of the following functions is called if the given interval has passed.
LazyCron::every3Minutes($seconds)
None
LazyCron::every45Minutes($seconds)
None
LazyCron::every4Days($seconds)
None
LazyCron::every4Hours($seconds)
None
LazyCron::every4Minutes($seconds)
None
LazyCron::every4Weeks($seconds)
None
LazyCron::every5Minutes($seconds)
None
LazyCron::every6Hours($seconds)
None
LazyCron::everyDay($seconds)
None
LazyCron::everyHour($seconds)
None
LazyCron::everyMinute($seconds)
None
LazyCron::everyWeek($seconds)
None
LazyCron::getTimeFuncName(int $seconds)
stringGet name of time function to hook for given number of seconds 
LazyCron::getTimeFuncSeconds(string $timeFuncName)
intGet number of seconds for given time function name or 0 if not found 
LazyCron::getTimeFuncs()
stringGet hookable time functions that are allowed, indexed by number of seconds they use 

Additional methods and properties

In addition to the methods and properties above, LazyCron also inherits the methods and properties of these classes:

API reference based on ProcessWire core version 3.0.251