内容简介:SystemD即为System Daemon,是linux下的一种init软件,开发目标是提供更优秀的框架以表示系统服务间的依赖关系,并依此实现系统初始化时服务的并行启动,
CentOS 7 可以在SystemD管理服务Service方式实现服务的自启动
SystemD即为System Daemon,是 linux 下的一种init软件,开发目标是提供
更优秀的框架以表示系统服务间的依赖关系,并依此实现系统初始化时服务的并行启动,
同时达到降低 Shell 的系统开销的效果。
这里假设需要启动
# /usr/share/autostartup/foobar.sh
STEP1.创建SystemD管理服务使用的.service文件
/usr/share/autostartup/foobar.service
以下是测试service文件,.service的具体编写,参考systemd相关文档
[Unit] Description=foobar Documentation=http://www.doc.com/doc.html After=network.target [Service] Type=simple WorkingDirectory=/home/foobar ExecStart=/usr/share/autostartup/foobar.sh ExecStop=/bin/kill -s QUIT $MAINPID Restart=always StandardOutput=syslog StandardError=syslog SyslogIdentifier=foobar User=foobar Group=foobar Environment= [Install] WantedBy=multi-user.target
STEP2.将编写好的service文件移动到 `/usr/lib/systemd/`下的指定目录下, 这里我们需要随系统启动,所以移动到
`/usr/lib/systemd/system/`下
cp /usr/share/autostartup/foobar.service /usr/lib/systemd/system/foobar.service
STEP3.配置和启动相应的Service
# 重新加载systemd的配置 systemctl daemon-reload # 配置服务为开机启动 systemctl enable foobar.service # 开启服务 systemctl start foobar.service #关闭服务 systemctl stop foobar.service
以上所述就是小编给大家介绍的《CentOS7 使用SystemD实现开机自启动和服务管理》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- Electron托盘&开机自启动
- CentOS6开机启动过程详解
- Linux设置Oracle开机自启动
- Centos7设置服务开机自启动
- Holer 1.2.0 发布,支持设置开机启动
- [CentOS7]redis设置开机启动,设置密码
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
URL 编码/解码
URL 编码/解码
UNIX 时间戳转换
UNIX 时间戳转换