Clear out user temp files

We have our Ignition service running under a domain user account. It appears over the last few years the App user folder\AppData\local\Temp directory is filling up with files that are being created when we use the system.file.getTempFile. Is there anyway we can make sure the directory regularly gets cleared out?

Deleting your temp files is on you. There’s no way for the platform to know when you are done with them. If you have some way to classify them, a gateway timer event script could be used to do the deletions.

Interesting. I wonder what this part of the documentation means?

Blockquote
Creates a new temp file on the host machine with a certain extension, returning the path to the file. The file is marked to be removed when the Java VM exits.

You should be seeing files created with system.file.getTempFile be deleted when Ignition restarts, or when the client restarts if created in that scope.

Under the hood, we’re just delegating to Java’s deleteOnExit method, so whether the deletion actually goes through is something we can’t guarantee. It also certainly won’t happen if your gateway were to ever crash.

Yeah, but services don’t stop often, and a crash won’t call such handlers. Any unexpected JVM stoppage will leave behind all of the accumulated files. You can’t leave such things to the JVM.