在 Fedora 35 上,我创建了自己的服务来安排备份。我在 /usr/local/bin/ 中有脚本,在 /lib/systemd/system/ 中有服务文件和计时器
ls -an /usr/local/bin/ 打印
-rwxr--r--. 1 0 0 3360 Dec 1 18:31 backup.sh
ls -an /lib/systemd/system/schedule-backup_root*
-rw-r--r--. 1 0 0 230 Dec 1 18:14 /lib/systemd/system/schedule-backup_root.service
-rw-r--r--. 1 0 0 388 Dec 1 16:49 /lib/systemd/system/schedule-backup_root.timer
但是当我启动服务 systemctl start schedule-backup_root.service
Dec 01 18:36:13 fallen-robot systemd[1]: Started Nightly snapshot backup job for ROOT volume.
Dec 01 18:36:13 fallen-robot systemd[75159]: schedule-backup_root.service: Failed to locate executable /usr/local/bin/backup.sh: Permission denied
Dec 01 18:36:13 fallen-robot systemd[75159]: schedule-backup_root.service: Failed at step EXEC spawning /usr/local/bin/backup.sh: Permission denied
Dec 01 18:36:13 fallen-robot systemd[1]: schedule-backup_root.service: Main process exited, code=exited, status=203/EXEC
Dec 01 18:36:13 fallen-robot systemd[1]: schedule-backup_root.service: Failed with result 'exit-code'.
我的服务文件如下所示:
[Unit]
Description=Nightly snapshot backup job for ROOT volume
[Service]
Type=simple
ExecStart=/usr/local/bin/backup.sh -s / -b /run/media/borko/BackupTest/ -t "Fallen Robot ROOT Backup Report"
[Install]
WantedBy=default.target
为什么它无法访问该文件?
禁用 SElinux 或将其设置为 permissive。
这将暂时禁用它。禁用后再次测试,看看是否能解决问题。