Ubuntu - Systemd - Wants

If you want service B to start when service A starts, you can use the Wants parameter to make it happen.

[Unit]
Wants = b.service

You can also use Before = or After = to specify the order.

[Unit]
Wants = b.service
Before = b.service

Sometimes, you may want service B to wait for service A to complete before starting itself.

[Service]
ExecStartPre=/bin/sleep 20

NOTE: This tells b.service to wait 20 seconds.


Reload systemd

Remember to reload systemd for the changes to take effect.

sudo systemctl daemon-reload