linux系统启动服务

系统服务路径:

root@firefly:/lib/systemd/system#

与之交互的工具 systemctl
列出linux上所有单元:

root@firefly:/lib/systemd/system# systemctl list-unit-files
root@firefly:/lib/systemd/system# systemctl list-unit-files --type-service

enable 不代表正在运行,表可以被启用的单元,
disable是被金庸的单元,
static 的不能直接启用,它们是其他单元所依赖的对象。

启动停止:
systemctl stop xx.service
systemctl start xx.service
如果某单元被禁用,可以先 systemctl enable该单元,将其启用

systemctl restart & systemctl reload + xx.service

自定义系统服务:
在相应路径下创建service文件:
systemd-qljown.service:
文件内容:

root@firefly:/lib/systemd/system# nl systemd-qljown.service
     1  #  SPDX-License-Identifier: LGPL-2.1+
     2  #
     3  #  This file is part of systemd.
     4  #
     5  #  systemd is free software; you can redistribute it and/or modify it
     6  #  under the terms of the GNU Lesser General Public License as published by
     7  #  the Free Software Foundation; either version 2.1 of the License, or
     8  #  (at your option) any later version.

     9  [Unit]
    10  Description=qlj define service
    11  #After=systemd-udevd.service
    12  #Before=systemd-networkd.service

    13  [Service]
    14  Type=oneshot
    15  ExecStart=/bin/bash /home/firefly/udev.sh


    16  [Install]
    17  WantedBy=multi-user.target
root@firefly:/lib/systemd/system#


 systemctl daemon-reload
 systemctl start systemd-qljown.service
 systemctl enable systemd-qljown.service
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值