2024-03-31

Syncthing as a service

To make Syncthing start automatically on Fedora, you can use systemd. This approach allows you to start Syncthing automatically at boot time under your user account, ensuring that it’s always running in the background without requiring manual intervention. Here’s how you can do it:

  1. Install Syncthing (if you haven’t already): You can install Syncthing from the default Fedora repositories. Open a terminal and run:

    sudo dnf install syncthing
    
  2. Enable and start Syncthing service for your user: systemd manages services through units. For each user, systemd can manage a separate instance of the Syncthing service. This is done by enabling and starting a “user” service, not a “system” service. This means the service will start automatically when your user logs in and will run under your user’s permissions.

    • Enable the service: This step tells systemd to start the Syncthing service automatically on user login.

      systemctl --user enable syncthing.service
      
    • Start the service now: To start the Syncthing service immediately without waiting for the next login or reboot, use the following command:

      systemctl --user start syncthing.service
      
  3. Verify the service is running: You can check that the Syncthing service is active and running with:

    systemctl --user status syncthing.service
    
  4. Accessing Syncthing: By default, Syncthing’s web interface will be available at http://localhost:8384/. You can use your web browser to access it and configure your folders and devices.

  5. Optional - Enable service to start at boot: While the above steps will start Syncthing on user login, if you want the service to start at boot time (before login), you will need to enable lingering for your user. This tells systemd to start user services at boot instead of at login. Run:

    sudo loginctl enable-linger $USER
    

    This command makes systemd start user services at boot time. It’s particularly useful if Syncthing needs to run on a headless server or a system where you don’t log in graphically.

Syncthing should now automatically start for your user account on Fedora, either at user login or at boot time (if lingering is enabled).