# Clear out user temp files

**URL:** <https://forum.inductiveautomation.com/t/clear-out-user-temp-files/28118>\
**Category:** Ignition\
**Created:** [September 9, 2019, 8:32pm UTC](https://forum.inductiveautomation.com/t/clear-out-user-temp-files/28118 "2019-09-09T20:32:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://forum.inductiveautomation.com/u/Jonathan)\
**Post date:** [September 9, 2019, 8:32pm UTC](https://forum.inductiveautomation.com/t/clear-out-user-temp-files/28118/1 "2019-09-09T20:32:59Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 9, 2019, 9:30pm UTC](https://forum.inductiveautomation.com/t/clear-out-user-temp-files/28118/2 "2019-09-09T21:30:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://forum.inductiveautomation.com/u/Jonathan)\
**Post date:** [September 9, 2019, 9:32pm UTC](https://forum.inductiveautomation.com/t/clear-out-user-temp-files/28118/3 "2019-09-09T21:32:48Z")

</div>

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.**

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [September 9, 2019, 9:46pm UTC](https://forum.inductiveautomation.com/t/clear-out-user-temp-files/28118/4 "2019-09-09T21:46:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 9, 2019, 9:50pm UTC](https://forum.inductiveautomation.com/t/clear-out-user-temp-files/28118/5 "2019-09-09T21:50:01Z")

</div>

Under the hood, we’re just delegating to Java’s [`deleteOnExit`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/File.html#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.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 9, 2019, 10:13pm UTC](https://forum.inductiveautomation.com/t/clear-out-user-temp-files/28118/6 "2019-09-09T22:13:58Z")

</div>

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.
