This is not possible right now in plain Lua, but you can easily develop a C/C++ plugin that periodically triggers a Lua function (in a thread) by calling “OrthancPluginRestApiPost()” on URI “/tools/execute-script”:
http://book.orthanc-server.com/developers/creating-plugins.html
The thread should be started (resp. stopped) on receiving event “OrthancPluginChangeType_OrthancStarted” (resp. “OrthancPluginChangeType_OrthancStopped”) in the change callback:
http://sdk.orthanc-server.com/group__Callbacks.html#ga78140887a94f1afb067a15db5ee4099c
Sébastien-