# Leftover .syncthing.tmp files

**URL:** https://forum.syncthing.net/t/leftover-syncthing-tmp-files/12149
**Category:** Support
**Created:** [September 13, 2018, 11:32am UTC](https://forum.syncthing.net/t/leftover-syncthing-tmp-files/12149 "2018-09-13T11:32:41Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![schneemensch](https://forum.syncthing.net/user_avatar/forum.syncthing.net/schneemensch/32/5216_2.png) [@schneemensch](https://forum.syncthing.net/u/schneemensch)
#### Post date: [September 13, 2018, 11:32am UTC](https://forum.syncthing.net/t/leftover-syncthing-tmp-files/12149/1 "2018-09-13T11:32:41Z")

</div>

I use Syncthing to distribute data from a central server to remote devices every night. For this I setup a new folder configuration and after the sync is reported to be complete to all devices I remove the folder from the config files.

I now noticed that on each remote device are about 50 syncthing tmp files with the name: .syncthing.fileName.tmp left over. I would like to leave the folder in a clean state.

Is there a cleaner way to remove the folder, which removes tmp files or should I do it by hand?

---

<div class="post-metadata">

### Author: ![imsodin](https://forum.syncthing.net/user_avatar/forum.syncthing.net/imsodin/32/3317_2.png) [@imsodin](https://forum.syncthing.net/u/imsodin)
#### Post date: [September 13, 2018, 11:43am UTC](https://forum.syncthing.net/t/leftover-syncthing-tmp-files/12149/2 "2018-09-13T11:43:26Z")

</div>

Temporary files are removed after 24h.  
However leftover `syncthing.*.tmp` files are a sign of incomplete or aborted sync progress, so you should probably investigate that (possible question: are the non-temporary files really equivalent to the source and are the temp files also equivalent or different?).

---

<div class="post-metadata">

### Author: ![schneemensch](https://forum.syncthing.net/user_avatar/forum.syncthing.net/schneemensch/32/5216_2.png) [@schneemensch](https://forum.syncthing.net/u/schneemensch)
#### Post date: [September 13, 2018, 12:01pm UTC](https://forum.syncthing.net/t/leftover-syncthing-tmp-files/12149/3 "2018-09-13T12:01:38Z")

</div>

Do I guess correctly, that they are not removed when the folder is not synced anymore?

I will run a thorough check, but as far as I have seen those are temporary copies of files that were removed on the master (probably during the downloading process) and therefore should not be there anymore.

---

<div class="post-metadata">

### Author: ![imsodin](https://forum.syncthing.net/user_avatar/forum.syncthing.net/imsodin/32/3317_2.png) [@imsodin](https://forum.syncthing.net/u/imsodin)
#### Post date: [September 13, 2018, 12:15pm UTC](https://forum.syncthing.net/t/leftover-syncthing-tmp-files/12149/4 "2018-09-13T12:15:02Z")

</div>

They are removed, if they are below an “active” folder root (active as in there is a Syncthing instance running and scanning this dir).

I didn’t check, but that sounds like a probable explanation. I.e. the temp file for the aborted item will stay around, and the subsequent deletion won’t be pulled in, because the item was never successfully pulled (i.e. it doesn’t exist, so pulling a deletion is a noop). And even if the deletion was pulled, I am not sure whether we do also check if there is a temp file and remove that as well (sounds like something we should do).

---

<div class="post-metadata">

### Author: ![AudriusButkevicius](https://forum.syncthing.net/user_avatar/forum.syncthing.net/audriusbutkevicius/32/277_2.png) [@AudriusButkevicius](https://forum.syncthing.net/u/AudriusButkevicius)
#### Post date: [September 13, 2018, 12:34pm UTC](https://forum.syncthing.net/t/leftover-syncthing-tmp-files/12149/5 "2018-09-13T12:34:00Z")

</div>

The scan deletes old temp files, not the pull.

---

<div class="post-metadata">

### Author: ![imsodin](https://forum.syncthing.net/user_avatar/forum.syncthing.net/imsodin/32/3317_2.png) [@imsodin](https://forum.syncthing.net/u/imsodin)
#### Post date: [September 13, 2018, 12:36pm UTC](https://forum.syncthing.net/t/leftover-syncthing-tmp-files/12149/6 "2018-09-13T12:36:24Z")

</div>

I know, but wouldn’t it makes sense if a pull deletion would do so too, e.g. in such a scenario:

1. Start pulling a file.
2. Pulling is aborted due to request failing due to file being deleted on the remote.
3. Next pulling iteration deletes the previously aborted file.

Current result: Temporary file still around.

Possibly better result: Temporary file also gets removed.

---

<div class="post-metadata">

### Author: ![schneemensch](https://forum.syncthing.net/user_avatar/forum.syncthing.net/schneemensch/32/5216_2.png) [@schneemensch](https://forum.syncthing.net/u/schneemensch)
#### Post date: [September 13, 2018, 12:37pm UTC](https://forum.syncthing.net/t/leftover-syncthing-tmp-files/12149/7 "2018-09-13T12:37:19Z")

</div>

I have the filewatcher enabled on all devices, could that mean that the scan which would trigger the delete is never triggered?

As far as I understand it the folder should be triggered, because the tmp file is changing in there, but I am not sure if you filter those triggers out.

---

<div class="post-metadata">

### Author: ![schneemensch](https://forum.syncthing.net/user_avatar/forum.syncthing.net/schneemensch/32/5216_2.png) [@schneemensch](https://forum.syncthing.net/u/schneemensch)
#### Post date: [September 13, 2018, 12:54pm UTC](https://forum.syncthing.net/t/leftover-syncthing-tmp-files/12149/8 "2018-09-13T12:54:29Z")

</div>

I have to make an correction on what i said before.

The files exist on both sides and are exactly identical. I checked all the files if they exist or if they are deleted on both sides and they actually are all existing on both the master as well as the slave.

I thought it might be deletions, because near the end of the sync are almost only deletions.

---

<div class="post-metadata">

### Author: ![AudriusButkevicius](https://forum.syncthing.net/user_avatar/forum.syncthing.net/audriusbutkevicius/32/277_2.png) [@AudriusButkevicius](https://forum.syncthing.net/u/AudriusButkevicius)
#### Post date: [September 13, 2018, 5:01pm UTC](https://forum.syncthing.net/t/leftover-syncthing-tmp-files/12149/9 "2018-09-13T17:01:08Z")

</div>

Even if the watcher is enabled, periodic scan still happens every hour.

---

<div class="post-metadata">

### Author: ![schneemensch](https://forum.syncthing.net/user_avatar/forum.syncthing.net/schneemensch/32/5216_2.png) [@schneemensch](https://forum.syncthing.net/u/schneemensch)
#### Post date: [September 14, 2018, 7:37am UTC](https://forum.syncthing.net/t/leftover-syncthing-tmp-files/12149/10 "2018-09-14T07:37:50Z")

</div>

I now wrote a script to check all files on all devices and I have between 50 and 450 leftover syncthing tmp files after syncing 300 000 files. In all of these cases the file was synced successfully and is identical to the original file.

I guess these are only leftovers which I can just delete with my script.

I am not sure if it is reasonable for you to do a cleanup once the folder is unsynced. I know my case of creating folders every day is not your usual usecase.

Thanks for your help.

---

<div class="post-metadata">

### Author: ![AudriusButkevicius](https://forum.syncthing.net/user_avatar/forum.syncthing.net/audriusbutkevicius/32/277_2.png) [@AudriusButkevicius](https://forum.syncthing.net/u/AudriusButkevicius)
#### Post date: [September 14, 2018, 8:44am UTC](https://forum.syncthing.net/t/leftover-syncthing-tmp-files/12149/11 "2018-09-14T08:44:55Z")

</div>

They do get cleaned up after 24 hours as I said. You can set the retention to 0 hours, and force a scan before you remove the folder to clean them up.

Or just `find . -name pattern -delete`

---

<div class="post-metadata">

### Author: ![schneemensch](https://forum.syncthing.net/user_avatar/forum.syncthing.net/schneemensch/32/5216_2.png) [@schneemensch](https://forum.syncthing.net/u/schneemensch)
#### Post date: [September 14, 2018, 11:43am UTC](https://forum.syncthing.net/t/leftover-syncthing-tmp-files/12149/12 "2018-09-14T11:43:20Z")

</div>

I will probably just clean them up with find like you said.

I checked the results again today and this time I found both: Files that were deleted on both sides and files that exist on both sides. This means that the temporary files are just left over from interrupted sync processes.

---

<div class="post-metadata">

### Author: ![AudriusButkevicius](https://forum.syncthing.net/user_avatar/forum.syncthing.net/audriusbutkevicius/32/277_2.png) [@AudriusButkevicius](https://forum.syncthing.net/u/AudriusButkevicius)
#### Post date: [September 14, 2018, 11:47am UTC](https://forum.syncthing.net/t/leftover-syncthing-tmp-files/12149/13 "2018-09-14T11:47:08Z")

</div>

Yes they are, as explained above, yet they get removed after 24hrs…

---

<div class="post-metadata">

### Author: ![schneemensch](https://forum.syncthing.net/user_avatar/forum.syncthing.net/schneemensch/32/5216_2.png) [@schneemensch](https://forum.syncthing.net/u/schneemensch)
#### Post date: [September 14, 2018, 11:54am UTC](https://forum.syncthing.net/t/leftover-syncthing-tmp-files/12149/14 "2018-09-14T11:54:21Z")

</div>

> [@imsodin](#):
>
> They are removed, if they are below an “active” folder root (active as in there is a Syncthing instance running and scanning this dir).

Since I am removing the folder before the 24h are over, they will not be removed. And even if they were I only need the folder for about 14h after the sync and it is getting removed soon after.

---

<div class="post-metadata">

### Author: ![system](https://forum-uploads.syncthingcdn.net/original/2X/0/0b50e0a202b22ae6a67190759e8c868805b8ed9f.png) [@system](https://forum.syncthing.net/u/system)
#### Post date: [October 14, 2018, 11:54am UTC](https://forum.syncthing.net/t/leftover-syncthing-tmp-files/12149/15 "2018-10-14T11:54:32Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
