通过 systemd 作为 root 运行时,Rsync 失败并出现网络错误

问题描述 投票:0回答:1

嘿,有一天我正在使用 rsync 设置拱形镜子

[Unit]
Description=Sync repo
Requires=network-online.target

[Service]
ExecStart=/bin/bash /root/sync-repo.sh
User=root
Group=root
Type=oneshot

当我尝试使用 systemd 运行它时,出现错误

$ systemctl start sync-repo
Job for sync-repo.service failed because the control process exited with error code.
See "systemctl status sync-repo.service" and "journalctl -xeu sync-repo.service" for details.

$ journalctl -fu sync-repo
Mar 30 07:50:23 arch-mirror bash[32312]: rsync error: error in socket IO (code 10) at 
clientserver.c(138) [Receiver=3.2.3]
Mar 30 07:50:23 arch-mirror systemd[1]: sync-repo.service: Main process exited, code=exited, status=10/n/a
Mar 30 07:50:23 arch-mirror systemd[1]: sync-repo.service: Failed with result 'exit-code'.
Mar 30 07:50:23 arch-mirror systemd[1]: Failed to start Rsync backup.
Mar 30 07:56:16 arch-mirror systemd[1]: Starting Sync repo...
Mar 30 07:56:16 arch-mirror bash[34025]: rsync: [Receiver] failed to connect to mirror.23m.com (212.83.32.30): Permission denied (13)

Mar 30 07:56:16 arch-mirror bash[34025]: rsync error: error in socket IO (code 10) at clientserver.c(138) [Receiver=3.2.3]
Mar 30 07:56:16 arch-mirror systemd[1]: sync-repo.service: Main process exited, code=exited, status=10/n/a
Mar 30 07:56:16 arch-mirror systemd[1]: sync-repo.service: Failed with result 'exit-code'.
Mar 30 07:56:16 arch-mirror systemd[1]: Failed to start Sync repo.

但是,当尝试直接运行 bash 脚本时,该过程成功完成。

操作系统发布: 名称=AlmaLinux 版本=9.3

linux rsync systemd
1个回答
0
投票

在我们的例子中,我们只是禁用了 SELinux,一切都工作正常

不是最好的解决方案,但它对我们有用

(我们没有任何其他东西可以在该机器上运行,只有 rsync)

© www.soinside.com 2019 - 2024. All rights reserved.