Thanks for your suggestions. I’ve replaced the last shell script, which deletes all temporary files, with a KM action.
For more information, see the wiki Searching the Forum for Answers section.