In my extension (a plugin) I want some SQL scripts to run every once in a while (some database cleanup operations); once a day or once a week would probably be enough. Doesn't need to be exactly in that interval, it would be well enough to be triggered if someone accesses the site.
In an ideal world those would probably be run by a cron script, but not everybody using my extension will have access to the crontab on their server, so the solution needs to work without cronjobs.
Searching for "joomla cronjob" and combinations of it I haven't yet found anything already existing in the Joomla framework (just additional extensions, like JPrc Cronjobs; but it needs to be either existing in the framework already or included into my extension).
Thinking about implementing it myself (since my plugin already runs on every site call anyway), the immediate solution coming to mind is storing a timestamp whenever doing the operation, and then for the next operation run, checking whether the appropriate interval has already passed.
However, where would I store the timestamp? A separate table seems complete overkill (although it would probably be the cleanest solution). Is there maybe some simple key-value store for Joomla extensions? I didn't see such a thing yet either.
So, my question boils down to:
- Is there a functionality within Joomla framework (working on Joomla >= 2.5) which triggers some code every once in an interval?
- Alternatively, is there a place to quickly and simply store a single key-value pair?