This seems like it should be a really simple question but I have had no luck in figuring it out. I have a service 'Alice':
[Unit]
Description=Alice
After=network.target
[Service]
Type=simple
Restart=on-failure
RestartSec=5
StartLimitInterval=0
ExecStart=sleep 30d
[Install]
WantedBy=multi-user.target
I would like to write a second service Bob such that:
- Bob starts when Alice has started successfully
- Bob starts because, and only because, Alice has started successfully (not triggered by system startup or other activity)
- Bob stops when Alice stops
I would like to achieve this without modifying Alice. Alice may be at times started with the system (via systemctl enable alice.service
) and in other situations only started manually. In practice there will be N-many additional services (Carol, Dave, Eve, ..) with their own unit files that all need to be started when Alice starts, and N may become a fairly large number.
I have experimented with various Unit settings, like PartOf, BoundTo, Requires, After, and no combination I've tried so far achieves the desired result of starting Bob by starting Alice. I've also found that invoking systemctl show bob.service
shows the expected settings after running systemctl daemon-reload
, but the reverse settings (ConsistsOf, BoundBy, RequiredBy) do not show up in systemctl show alice.service
, in apparent violation of the documentation.
I see no errors in the system log when invoking daemon-reload, or when starting Alice which would explain why Bob does not start.
Is it possible to do what I want to do? If so how do I troubleshoot such a problem? FWIW I am doing these experiments on RHEL 8.7 and systemd 239.