Cron event
Cron is a utility which executes scheduled tasks. If your plugin needs to run regular maintenance, catch ipCronExecute event.
System passes an $info array with usefull data to help you execute maintenance tasks on the right time.
<?php //Plugin/MyPlugin/Event.php file namespace Plugin\MyPlugin; class Event { public static function ipCronExecute($info) { $info['lastTime']; //timestamp when cron had been executed for the last time $info['test']; //flag if cron is running in a test mode if ($info['firstTimeThisYear'] || $info['test']){ // Execute this code once a year } if ($info['firstTimeThisMonth'] || $info['test']){ // Execute this code once a month } if ($info['firstTimeThisWeek'] || $info['test']){ // Execute this code once a week } if ($info['firstTimeThisDay'] || $info['test']){ // Execute this code once a day } if ($info['firstTimeThisHour'] || $info['test']){ // Execute this code once an hour } } }
By default, cron tasks are executed once an hour, by "fake cron". Fake means that it is not a real cron service. This function is executed on one of the visits on your website. If nobody visits your website, cron will not be executed. Also, you can't be sure that cron will be executed on exact timing.
You can disable "fake cron" in Configuration section of ImpressPages and set up your server to execute cron. Your cron's URL address is displayed in Config section of ImpressPages admin panel and looks as follow http://www.example.com/?pa=Cron&pass=myCronPassword. You can check how the cron works by pasting the mentioned URL address into your browser's address bar.
If you, as a developer, need to check the execution of all cron tasks, add test=1 variable to your website's URL (e.g., http://www.example.com/?pa=Cron&pass=myCronPassword&test=1).