Anton Ryzantsev
Anton Ryzantsev

Reputation: 11

systemd start service after another one stopped issue

I have 2 services that i need to start. First service has download jobs required for second service.

First service

[Unit]
Description=First
After=network.target

Second service

[Unit]
Description=Second
After=First

Problem is they both start at the same time, i need second service to wait until first one is dead. I don't wait to use sleep because download jobs can be big. Thank you.

Upvotes: 1

Views: 1584

Answers (1)

Yashgiri Goswami
Yashgiri Goswami

Reputation: 181

In your first service add

ExecStopPost = /bin/systemctl start Second

what this does is when the service terminates the above option is activated and thus second service is called.

This particular option(ExecStopPost) allows you to execute commands that are executed after the service is stopped. This includes cases where the commands configured in ExecStop= were used, where the service does not have any ExecStop= defined, or where the service exited unexpectedly.

Upvotes: 2

Related Questions