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}

  • 相关阅读:
    HDU 3436 Queuejumpers
    POJ 3580 SuperMemo
    HDU 2871 Memory Control
    Android 实现显示文字的Gallery
    Android 使用地图
    Android 深入的研究一下蓝牙
    手机录制视频demo
    用android来实现图片的绘制以及旋转缩放案例分析
    TextView 自动滚动(跑马灯)
    Android腾讯微博客户端开发一:在下方的Tab的实现
  • 原文地址:https://www.cnblogs.com/yooma/p/8244776.html
Copyright © 2011-2022 走看看