3

On Fedora 35, I create my own service to schedule a backup. I have the script in /usr/local/bin/ and service files plus timer in /lib/systemd/system/

ls -an /usr/local/bin/ prints

-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

but then when I start the service 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'.

My service file looks like this:

[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

Why it cannot access the file?

1 Answer 1

9

Set SElinux to permissive:

setenforce 0

This will disable it temporarily. Test again after disabling it, and see if this solves the issue.

To disable it permanently (Source), in the /etc/selinux/config file, set:

SELINUX=disabled

and reboot the system.

1
  • 2
    I solved it by sudo restorecon -rv /usr/local/bin/backup.sh. But I will accept your answer as it is on point! Commented Dec 2, 2021 at 10:45

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.