写一个linux同步文件脚本
时间: 2024-05-05 09:18:47 浏览: 85
Sure, I can help you with that! Here's an example script for syncing files between two Linux machines using rsync:
```
#!/bin/bash
# Source and destination directories
src_dir="/path/to/source/dir"
dest_dir="/path/to/destination/dir"
# Remote machine info
remote_user="username"
remote_ip="192.168.0.100"
# Run rsync to sync files
rsync -avz --delete-before ssh $src_dir $remote_user@$remote_ip:$dest_dir
```
This script will synchronize all files in the source directory to the destination directory on a remote machine with the specified IP address and username. The `--delete-before` option deletes any files in the destination directory that don't exist in the source directory.
Let me know if you have any further questions!
阅读全文