一、问题场景
ubuntu22.04中配置双机热备,使用rsync和inotify实现数据的增量同步。
其中inotify是内核自带的监控文件变动的工具。但是和cron不同的是,inotify并没有作为可以开机启动的服务。所以必须由脚本启动。
为了和rc.local体系兼容,也为了方便以后添加需要开机运行的命令,所以自己写一个开机运行/etc/rc.local的systemd服务
rc-local.service大致内容
[Unit] Description=/etc/rc.local //命名,或者叫备注
Compatibility After=iptables.service
syslog-ng.service
[Service]
Type=oneshot
ExecStart=/etc/rsyncd/rc.local //服务要执行的脚本路径
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
~