[systemd-devel] If systemd service fails how to get a dependency service to fail also

Andrei Borzenkov arvidjaar at gmail.com
Sat Apr 25 06:19:05 UTC 2020


24.04.2020 16:57, John пишет:
> I'd like to have systemd (user mode) call a bash script with different
> tokens under two conditions:
> 1) When the user starts/stops a service (token would be either "sync"
> or "unsync")
> 2) When a timer tells it to run (token would be "sync")
> 
> Thus far, I have been accomplishing these with 1 service and 1
> service/timer combo:
> 
> All three files can be found here for reference:
> https://github.com/graysky2/profile-sync-daemon/tree/ce290b54069b015879f53d631f82ed97bfe73d47/init
> 
> So the user starts psd.service and both psd-resync.{service,timer} get
> activated and run as expected.  The problem is when the script that
> psd.service calls ends in an error state...

ps.service does not call any script on startup.

> 
> 1) psd.service remains in an active state
> 2) psd-resync.timer remains active
> 
> I'd like:
> 1) both psd.service and psd-resync.service to both end in an error state.
> 2) psd-resync.timer to get deactivated
> 

Assuming service that fails is psd-resync.service, as far as I can tell
the only way is to add BindsTo=psd-resync.service to both psd.service
and psd-resync.timer.

> I've been through the man pages for systemd.service and systemd.timer
> to the point where I am confused who to achieve this.  What is the
> right strategy using services and a timer to deliver on this?
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
> 



More information about the systemd-devel mailing list