0

System:

  • RHEL 7.4, systemd 219

Units:

  • binary1.service
  • binary2.service
  • binary2.timer

What I want:

  • When starting and stopping binary1.service, binary2.timer will be started and stopped.
  • When bianry2.timer is started and stopped, binary2.timer will start and stop, but not affect the state of binary1.service.

Problem:

  • I have tried using a variety of combinations with Requires, After, PartOf, and BindsTo. I cant seem to find the right combination to make this work. The closet I have is
#binary1.service 
[Unit] 
BindsTo=binary2.timer

Which will start and stop binary2.timer is binary1.service is started or stopped. However If bianry2.timer is started or stopped, this will effect the service of binary1.service.

What am I missing?

Dave
  • 229
  • 2
  • 10
  • 1
    I don't know if this is possible. It certainly sounds like a very unusual scenario. Can you give any more context about what these services and timers are, and why they should interact (or not interact) in this strange way? – Michael Hampton Aug 26 '20 at 00:53
  • We want to be able to start and stop binary1.service and binary2.timer when starting and stopping binary1.service. - binary1.service, works as a watchdog service. - binary2.service, is a service that cleans up files that are created. - binary2.timer, is a timer that runs the binary2.service. Is this unusual? – Dave Sep 02 '20 at 14:37
  • Do you really need a second service at all? Would it be sufficient to run your cleanups using `ExecStopPost=`? – Michael Hampton Sep 02 '20 at 14:44
  • Are you suggesting something like ```ExecStopPost=systemctl stop binary2.timer```? Then remove the "BindsTo" entry? After more testing, I scrapped using "BindsTo" and adjusted the binary2.timer to use ```Requires=binary1.service After=binary1.service``` Now when I restart binary1.service it starts both, and when I stop binary1.service it stops both. Would be nice to be able to use "start" to start both. – Dave Sep 02 '20 at 15:01
  • No, I'm suggesting you run the actual commands that need to be run to do the cleanup. – Michael Hampton Sep 02 '20 at 15:01
  • By "Clean up" you are referring to systemd clean up of services that I am trying to achieve (Start and stop the binaries that systemd is trying to start and stop)? – Dave Sep 02 '20 at 15:04
  • Since you still haven't actually said what these services do in enough detail, I'm not sure I can really help much more. "Clean up" was _your_ description of what the program run by binary2.service does. – Michael Hampton Sep 02 '20 at 15:07

0 Answers0