Timetable for syncthing

Syncthing is very CPU hungry and it seems to bother users. If a lot of data changes in a short period of time it can get pretty sticky.

That’s why I’m looking for a way to “Syncthing” automatically up and down depending on the time. This could be used to postpone the synchronization to the night if it doesn’t bother anyone.

The best thing would be a feature that automatically pauses Syncthing at a certain time, and after a certain time the pause is canceled again. That would solve the problem.

I use Syncthing together with the “nssm”. Perhaps there is also a method how to switch the service on and off with nssm depending on the time. But I have not found a way to operate nssm time-controlled.

Can someone give me some ideas on this? How do you do this ?

You can easily switch services on and off using Task Scheduler. There is no specific guide for doing it for NSSM, but you can find basic instructions on how to set up a new task under https://docs.syncthing.net/users/autostart.html#autostart-windows-taskschd. Of course, specific commands and triggers will differ, but those you will likely need to figure out and customise to your needs. The built-in command to manage services is Windows is sc (or the old net).

I would actually rather suggest to run Syncthing with idle priority. This way Windows will simply prevent the syncthing.exe process from affecting other system resources. This can be done easily when launching the process from command line with start /low syncthing.exe (or in the XML file when using Task Scheduler). NSSM seems to have a specific setting to change process priority too.

If you do go this route though, then you must also disable Set Low Priority in the Advanced Configuration (see https://github.com/syncthing/syncthing/issues/6597). On a side note, this setting changes only CPU priority, while in my experience the key is to lower I/O priority together with it, as Syncthing is extremely I/O hungry when scanning. On the other hand, the aforementioned command line and Task Scheduler methods lower both CPU, I/O and RAM priorities.

I personally run Syncthing like that even on an old Intel Atom based Windows tablet, and have yet to experience any slowdowns because of it, even when processing a lot of data. Windows really does a pretty good with preventing low-priority processes from affecting system responsiveness.

2 Likes

As tomasz86 said, you can stop the service with a scheduled run of

sc stop <syncthing-service-name>

and start ist again with start.

You can also use the api (or maybe even syncthing-cli) to set all folders (and devices) to paused, to “pause” Syncthing.

In a FreeBSD or Linux OSs you can ‘renice’ the process. The higher the “nice” value the nicer (lower priority) it is.

# renice 10 39072
39072: old priority 0, new priority 10


last pid:   471;  load averages:  0.16,  0.09,  0.03                                  up 23+23:20:39  14:28:57
33 processes:  1 running, 32 sleeping
CPU:  0.0% user,  0.0% nice,  0.0% system,  0.0% interrupt,  100% idle
Mem: 783M Active, 8553M Inact, 1004M Laundry, 2401M Wired, 1556M Buf, 3124M Free
Swap: 3598M Total, 35M Used, 3563M Free

  PID USERNAME  THR PRI NICE   SIZE    RES STATE   C   TIME     CPU COMMAND
39072 syncthin   24  30   10  1249M   610M uwait   2   9:26   0.02% syncthing
39071 syncthin   18  40    0   710M 10944K uwait   4   0:01   0.00% syncthing
39070 syncthin    1  20    0  6376K  1016K piperd  3   0:00   0.00% daemon

I haven’t bother to figure out yet how to set this in the startup scripts because I don’t have any issues with lack of cpu capability.