Multiple instances of Unison with same profile

Michael von Glasow <[email protected]> Fri, 17 May 2024 00:33:29 +0300
Newsgroups gmane.network.unison.general
Message-ID <[email protected]>
Hi all,

How does Unison behave if two instances of it are running with the same
profile (in particular, when one root is accessed via SSH)? This might
be the case if Unison runs as a cron job and this one particular time
there happens to be a lot of data that needs to be synced, so the next
cron job starts before the previous one finishes.

 From what I have noticed, I’ll end up with two Unison processes running
on my system. However, I have not examined in detail what the second
instance does.

Is such a situation safe? Or should I take measures to prevent it?

Where does Unison place lock files, and what do they refer to (a root, a
single file or something else)?

If one Unison instance is already running, would another instance
running against the same pair of roots wait for the first instance to
finish? Or would it start syncing files on its own, provided they are
not locked and have not changed (e.g. by the other instance) during sync?

Right now I am preventing multiple instances by running `flock -n
/var/lock/unison unison`, but I am wondering whether this is necessary
at all and whether there is a more elegant solution.

For people pointing out the option of running Unison with `-repeat
wait+TIME`: an upside of cron is that sync starts at a predictable time
(off-peak hours), whereas with `-repeat TIME` it would drift by the
duration of each sync run. Changes happen mostly on one system, and the
Unison cron job runs on the other – would `-repeat wait` pick up remote
changes at all?

Any insight is appreciated.

Michael

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].