← 返回命令列表

Linux command

lsyncd 命令

网络

需要网络或远程资源。

常用示例

Sync directories locally

lsyncd -rsync [/source/] [/destination/]

Sync to remote server

lsyncd -rsyncssh [/local/] [user@host] [/remote/]

Use configuration file

lsyncd [config.lua]

Run in foreground with logging

lsyncd -log all [config.lua]

Dry run

lsyncd -nodaemon -log all [config.lua]

Specify log file

lsyncd -logfile [/var/log/lsyncd.log] [config.lua]

说明

lsyncd (Live Syncing Daemon) watches directories for changes and synchronizes them in real-time. It uses inotify on Linux to detect file changes efficiently. When changes occur, lsyncd waits briefly (delay) to aggregate multiple changes, then triggers rsync to synchronize. This approach handles burst writes efficiently while maintaining near-real-time sync. Configuration files use Lua scripting for flexibility. They define sync pairs, exclude patterns, rsync options, and can implement custom sync logic. The tool works with both local directories and remote servers via SSH. Multiple sync pairs can run simultaneously from a single configuration. Common uses include backup systems, cluster file synchronization, and development environments where files need to stay synchronized across machines.

参数

-rsync _SOURCE_ _DEST_
Simple rsync sync mode.
-rsyncssh _SOURCE_ _HOST_ _DEST_
Rsync over SSH to remote host.
-nodaemon
Run in foreground, don't daemonize.
-log _LEVEL_
Set log level (all, scarce, normal, error).
-logfile _FILE_
Write logs to file.
-pidfile _FILE_
Write PID file.
-delay _SECONDS_
Delay before syncing (aggregation window).
-insist
Keep trying on startup errors.
-version
Show version.
-help
Show help.

FAQ

What is the lsyncd command used for?

lsyncd (Live Syncing Daemon) watches directories for changes and synchronizes them in real-time. It uses inotify on Linux to detect file changes efficiently. When changes occur, lsyncd waits briefly (delay) to aggregate multiple changes, then triggers rsync to synchronize. This approach handles burst writes efficiently while maintaining near-real-time sync. Configuration files use Lua scripting for flexibility. They define sync pairs, exclude patterns, rsync options, and can implement custom sync logic. The tool works with both local directories and remote servers via SSH. Multiple sync pairs can run simultaneously from a single configuration. Common uses include backup systems, cluster file synchronization, and development environments where files need to stay synchronized across machines.

How do I run a basic lsyncd example?

Run `lsyncd -rsync [/source/] [/destination/]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -rsync _SOURCE_ _DEST_ do in lsyncd?

Simple rsync sync mode.