Start systemd service after specific service?

user2312578 picture user2312578 · Feb 17, 2014 · Viewed 140.9k times · Source

I have a general question. How does one start a systemd unit *.service after a particular *.service has started successfully?

More specific question is, how do I start website.service only after mongodb.service has started? In other words website.service should depend on mongodb.service.

Answer

user2312578 picture user2312578 · Feb 17, 2014

In the .service file under the [Unit] section:

[Unit]
Description=My Website
After=syslog.target network.target mongodb.service

The important part is the mongodb.service

The manpage describes it however due to formatting it's not as clear on first sight

systemd.unit - well formatted

systemd.unit - not so well formatted