Search code examples
servicesystemd

Start systemd service after specific service?


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.


Solution

  • 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