刘总的笔记小站

生活常识,娱乐搞笑,编程技巧,智能家居,深度学习,网络神经,数据挖掘

添加一个systemd开机启动服务项

系统服务systemd是一个替代init管理开机启动项,以及服务依赖的一组命令。

传统init启动进程或者服务通过编写init.d下conf,作为启动重启停止的操作命令。

系统服务systemd替代init即pid为1,可以并行启动服务,服务启动状态顺序清晰可追溯。


1,编辑systemd默认加载的配置

#nano /etc/systemd/system/ftpServer.service
#vim /etc/systemd/system/ftpServer.service


2,设置使能服务

systemctl enable ftpServer.service


3,重启系统检查状态

systemctl list-unit-files

其他查询命令:
systemctl status
systemctl --failed
systemctl list-units
systemctl list-unit-files

其他操作命令:
systemctl start ftpServer.service
systemctl status ftpServer.service
systemctl is-enabled ftpServer.service

其他无关命令:
service --status-all
update-rc.d xxx defaults NN


/etc/systemd/system/ftpServer.service

#nano ftpServer.service
#vim ftpServer.service

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if ftpServer is executable.
[Unit]
Description=ftpServer service
ConditionFileIsExecutable=/root/ftpServer
After=network.target

[Service]
Type=forking
ExecStart=/root/ftpServer
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no

[Install]
WantedBy=multi-user.target
Alias=ftpServer.service



发表评论:

控制面板
您好,欢迎到访网站!
  查看权限
搜索
«   2024年9月   »
1
2345678
9101112131415
16171819202122
23242526272829
30
网站分类
最新留言
文章归档
网站收藏
友情链接
图标汇集
Powered by Z-BlogPHP

  • Copyright ©2021 @liuzong All rights reserved.
  • 陕ICP备17016542号