lilsync manages its own background daemon via start/stop, but running
it under systemd instead gets you automatic restarts, boot-time startup, and
journalctl logging. The units here use lilsync watch (foreground) as
ExecStart, since start forks into the background and would leave systemd
unable to track the process.
Use lilsync.service:
-
Edit
User=and theExecStartfolder path. -
Install and enable it:
sudo cp lilsync.service /etc/systemd/system/lilsync.service sudo systemctl daemon-reload sudo systemctl enable --now lilsync
To sync more than one folder, use the template unit lilsync@.service and
run one instance per folder, identified by the %i instance name.
-
Edit
User=inlilsync@.service, then install it:sudo cp lilsync@.service /etc/systemd/system/lilsync@.service
-
For each folder, create a config file under
/etc/lilsync/<name>.conf(seephotos.conf.example):sudo mkdir -p /etc/lilsync sudo install -m 0644 photos.conf.example /etc/lilsync/photos.conf # edit /etc/lilsync/photos.conf to point LILSYNC_FOLDER at the real path -
Enable and start each named instance — the part after
@(e.g.photos) selects which.conffile is loaded and becomes the instance name forsystemctl/journalctl:sudo systemctl daemon-reload sudo systemctl enable --now lilsync@photos sudo systemctl enable --now lilsync@docs
-
Check status and logs per instance:
systemctl status lilsync@photos journalctl -u lilsync@photos -f
-
Stop or disable a single instance without affecting the others:
sudo systemctl stop lilsync@photos sudo systemctl disable lilsync@photos
Pass any extra flags (--name, --poll, --interval-ms,
--announce-interval-secs, --port) directly in ExecStart, or add them to
the per-instance .conf file and reference them the same way as
${LILSYNC_FOLDER}.
Each instance needs its own RPC listen port. By default lilsync picks a free
port on first run and persists it in <folder>/.lil/port, so instances do
not collide. To pin ports explicitly (e.g. for firewall rules), give each
instance its own --port:
LILSYNC_FOLDER=/home/youruser/photos
LILSYNC_OPTS=--port 7421and use ExecStart=/usr/local/bin/lilsync watch ${LILSYNC_FOLDER} $LILSYNC_OPTS.