Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

9
  • This is a very elegant solution, and definitely what I would do. You can even use user units if you'd prefer to not run as root.
    – onwsk8r
    Commented May 17 at 17:41
  • Looks very elegant indeed, and gives me the additional benefit of being able to start synchronization manually when I need it, without having to worry about collisions with the next scheduled run. Running as a non-root user is pretty much mandatory with Unison, though – it is not intended to run as root.
    – user149408
    Commented May 17 at 18:29
  • @user149408 In that case you could specify User= in the service unit with a username or uid, and it will start the service as that user. Or as @onwsk8r mentioned, you can define both units (service and timer) entirely under a user if you prefer, though how exactly that's configured (and whether it starts on boot vs login) would depend on your distro. Personally I just define all my services as system services and configure them to run as a user if necessary.
    – Bob
    Commented May 18 at 2:30
  • 1
    @user149408 I'm not sure WorkingDirectory can take a ~ alias, you probably need the absolute path. IIRC it's normally recommended that ExecStart uses an absolute path too, though not strictly required.
    – Bob
    Commented May 18 at 15:37
  • 1
    @user149408 I suspect you may have meant simple, since single does not appear to exist. That said, exec is a better default if possible, since it has better error handling. Good catch on the WorkingDirectory
    – Bob
    Commented May 23 at 0:10