Problem with systemd timer

barrowcroft

New Member
Joined
Jan 8, 2025
Messages
10
Reaction score
3
Credits
83
I have a bash script that user rsync to incrementally backup my home dir to an external usb drive mounted via fstab.
I have a service to run the script as follows:

[Unit]
Description=backup service

[Service]
ExecStart=systemd-inhibit --what=idle:sleep:shutdown --who="Backup Service" --why="Running backup service"--mode=block /usr/local/bin/backup.sh


With a timer as follows:

[Unit]
Description=backup timer

[Timer]
OnCalendar=--* 06:00:00
OnCalendar=--* 07:00:00
OnCalendar=--* 08:00:00
OnCalendar=--* 09:00:00
OnCalendar=--* 10:00:00
OnCalendar=--* 11:00:00
OnCalendar=--* 12:00:00
OnCalendar=--* 13:00:00
OnCalendar=--* 14:00:00
OnCalendar=--* 15:00:00
OnCalendar=--* 16:00:00
OnCalendar=--* 17:00:00
OnCalendar=--* 18:00:00
OnCalendar=--* 19:00:00
OnCalendar=--* 20:00:00
OnCalendar=--* 21:00:00
OnCalendar=--* 22:00:00

Persistent=true
WakeSystem=true

[Install]
WantedBy=timers.target

The whole thing works well. The backups run and completes within a matter of seconds.

However, the next day, the first time the back up should run, the journal gives me:

Jan 19 06:00:29 pop-os systemd[1]: Started backup service.
Jan 19 06:00:29 pop-os systemd-inhibit[57950]: Failed to inhibit: The operation inhibition has been requested for is already running
Jan 19 06:00:29 pop-os systemd[1]: backup.service: Main process exited, code=exited, status=1/FAILURE
Jan 19 06:00:29 pop-os systemd[1]: backup.service: Failed with result 'exit-code'.

Which seems to imply the script is already in use, but i know it completed successfully.

Could anyone tell me what I am missing.
many thanks
 


If i run 'systemctl daemon-reload', everything resumes as normal; the backup runs every hour till 10pm, and then crashes again at 6:00am when the cycle resumes.
 
Actually, to be clear, the timer works fine; the system wakes up and runs the service, but when the service starts the 'systemd-inhibit' fails. It is strange, the 'systemd-inhibit' works ok every hour during the day, but next day fails for some reason.
 
Last edited:

Staff online


Top