systemctl设置开机自启动 win

zsxwz 20/02.09 12:58 985


linux开机自启的方法比较多,systemctl算是一个比较麻烦的方法,但是比较稳定。


systemd有系统和用户区分;

系统/user/lib/systemd/system/

用户/etc/lib/systemd/user/)

一般系统管理员手工创建的单元文件建议存放在

/etc/systemd/system/目录下面

[Unit]
Description=nginx - high performance web server
# 描述
Documentation=http://nginx.org/en/docs/
# 文档
After=network.target remote-fs.target nss-lookup.target 
# 启动顺序
[Service]
Type=forking/simple/oneshot/...
# 启动类型
PIDFile=/run/nginx.pid
# pid 
ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
# 启动命令或者脚本
ExecStop=/bin/kill -s QUIT $MAINPID
# 停止命令
PrivateTmp=true
[Install]
WantedBy=multi-user.target
# 单元被允许运行需要的弱依赖性单元


常用命令:

systemctl enable xxx.service
# 激活

systemctl enable xxx.service
# 停用

systemctl start xxx.service
#开启

systemctl restart xxx.service
# 重启

systemctl stop xxx.service
# 关闭

systemctl status xxx.service
# 状态




上一篇:openvz的vps开启bbr
下一篇:snapd下载使用代理
最新回复 (2)
  • mlzcnswmxq 0
    引用 3
    每日鸡汤:众里寻她千百度,蓦然回首,那人依旧对我不屑一顾。
    21/11.19 14:40 0 回复
  • Bil 0
    引用 2
    不错
    20/02.25 19:35 0 回复
    • 姿势论坛—姿势小王子
      4
返回
发新帖
友情链接
免责声明:本站部分资源来源于网络,如有侵权请发邮件(mail@zsxwz.com)告知我们,我们将会在24小时内处理。