特定服务后启动systemd服务? [英] Start systemd service after specific service?

查看:37
本文介绍了特定服务后启动systemd服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个一般性的问题.在特定的 *.service 成功启动后,如何启动 systemd 单元 *.service?

更具体的问题是,如何在 mongodb.service 启动后才启动 website.service ?换句话说,website.service 应该依赖于 mongodb.service.

解决方案

在 .service 文件中的 [Unit] 部分:

[单位]说明=我的网站After=syslog.target network.target mongodb.service

重要的部分是mongodb.service

手册页对其进行了描述,但是由于格式的原因,乍一看并不那么清楚

systemd.unit - 格式良好

systemd.unit - 格式不太好

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.

解决方案

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

这篇关于特定服务后启动systemd服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆