I need to do some additional processing after a Drupal page has been sent.
I know I could fire a background shell command, but I need the current Drupal execution context to be maintained.
I've spent a lot of time looking, but I can't find any documentation in this regard. This is surprising because it must surely be a common requirement.
The only real idea I have is to fire up Drupal (again) via a shell command (exec, etc) and supply it with a pseudo path which would invoke the continued processing. But this seems unnecessarily complex/wasteful.
Any pointers greatly appreciated, tks.
UPDATE: Based on Googletorp and Matt's replies, I just want to point out that I'm not doing housekeeping with this additional processing. Without going into too much detail, I have a number of pages whose content is based on multiple nodes. If one of these child nodes changes then the page needs to be updated immediately, but there is no reason why the user who updated the child node needs to be kept waiting while this happens.
So, the control flow would be:
UPDATE CHILD NODE
RETURN UPDATED CHILD NODE VIEW TO USER (this is where Drupal would normally terminate)
REGENERATE PARENT PAGE
EXIT
Neither Cron nor the rules module have the immediacy I require - but thanks for your input.