Most module handlers are triggered by certain actions: onLoad, onOutput, onBeforeSync, etc. However, you might have tasks that you want to simply run on a certain schedule, like a cron job.
To do this, you’ll add your code into an exec/ folder in your module, and insert it into the livewhale scheduler. Here’s an example for a module called foobar that has code you want to run daily.
livewhale/client/modules/foobar/exec/foobar_daily.php
<?php
// To install, run
// REPLACE INTO livewhale_scheduler VALUES("foobar_daily", "foobar_daily", NOW(), 84600, "private");
// in database.
// Any code in this file will run daily. You can use $_LW functions in this code.
?>
The livewhale_scheduler table tracks time in seconds, so you can use any of the following times in the REPLACE INTO command for setting the frequency of your code:
Hourly: 3600
Daily: 84600
Weekly: 604800
Monthly: 2592000
You can visit /livewhale/?lw_debug=7 to see the next time each scheduled task is set to run, and you can reset them to run more often when testing.