A friend of mine recently asked me how to modify a PHP script that collects data into an RRDtool database so it could be triggered more often than once per minute. He is currently using cron(8) to trigger the script.
Of course cron(8) has a granularity of 1 minute so there is nothing that can be done there.
The basic solution is to start the script once and have it loop infinitely with each loop iteration performing the action and then waiting until the next time the action should be performed. Thus the run interval can be specified with sub-second precision.
There are a few minor catches though:
php.ini
used for the web server does not include this extension.Explaining all of this to someone who can read and unterstand code, even modify it, but who is not an actual software developer, seemed complicated. So I decided on building some heavily commented sample code to illustrate the concepts and as a potential starting point for useful scripts based on this concept. You can find it here: https://github.com/fiwswe/simpleservice