zoukankan      html  css  js  c++  java
  • systemd管理服务

    [root@zbs-staging-api system]# cat /lib/systemd/system/ncmulti@.service 
    [Unit]
    Description=many on %i
    After=network.target
    
    [Service]
    PIDFile=/var/run/nc.%i.pid
    #Type=forking
    ExecStart=/usr/bin/nc -l %i # 命令行执行时在@后传递变量
    
    [Install]
    WantedBy=multi-user.target


    #一条命令启动一个进程

    [root@zbs-staging-api system]# systemctl start ncmulti@5733
    [root@zbs-staging-api system]# systemctl start ncmulti@5734
    [root@zbs-staging-api system]# systemctl start ncmulti@5732

    [root@zbs-staging-api system]# ps aux | grep nc
    root 19599 0.0 0.0 45676 2080 ? Ss 20:24 0:00 /usr/bin/nc -l 5735
    root 19616 0.0 0.0 45676 2080 ? Ss 20:24 0:00 /usr/bin/nc -l 5733
    root 19622 0.0 0.0 45676 2076 ? Ss 20:24 0:00 /usr/bin/nc -l 5734
    root 19628 0.0 0.0 45676 2080 ? Ss 20:24 0:00 /usr/bin/nc -l 5732

    #一条命令启动多个进程

    [root@zbs-staging-api system]# systemctl start ncmulti@{9283,9282,9284} 或者 systemctl start ncmulti@{9282..9284}

    [root@zbs-staging-api system]# ps aux | grep nc
    root 19948 0.0 0.0 45676 2076 ? Ss 20:26 0:00 /usr/bin/nc -l 9283
    root 19949 0.0 0.0 45676 2076 ? Ss 20:26 0:00 /usr/bin/nc -l 9282
    root 19950 0.0 0.0 45676 2076 ? Ss 20:26 0:00 /usr/bin/nc -l 9284

    [root@zbs-staging-api system]# systemctl restart ncmulti@{9283,9282,9284} #批量重启
    [root@zbs-staging-api system]# ps aux | grep nc
    root 19959 0.0 0.0 45676 2080 ? Ss 20:27 0:00 /usr/bin/nc -l 9283
    root 19962 0.0 0.0 45676 2076 ? Ss 20:27 0:00 /usr/bin/nc -l 9282
    root 19963 0.0 0.0 45676 2076 ? Ss 20:27 0:00 /usr/bin/nc -l 9284

    # 启动多进程传递有序参数

    systemctl start storage@sd{b..m}

  • 相关阅读:
    iOS 简单获取当前地理坐标
    iOS 企业账号申请证书和打包ipa
    iOS 代码片段的添加!
    iOS 扩展类方法之category!
    iOS 数组和字典排序
    iOS 字符串NSString 的一些常用方法
    iOS 一些常见问题
    iOS 数据库sqlite完整增删改查操作
    iOS pch文件的创建
    iOS 通过网络请求获取图片的下载歌曲
  • 原文地址:https://www.cnblogs.com/yooma/p/8244776.html
Copyright © 2011-2022 走看看