User Tools

Site Tools


ubuntu:systemd:wants

Ubuntu - Systemd - Wants

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

  • In the [Unit] section of a systemd .service file, add a line like this:
[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.

  • Then you can add the following lines in the [Service] section of the b.service file.
[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
ubuntu/systemd/wants.txt · Last modified: 2023/06/03 10:22 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki