[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 0.0 0.0 45676 2076 ? Ss 20:26 0:00 /usr/bin/nc -l 9283
root 0.0 0.0 45676 2076 ? Ss 20:26 0:00 /usr/bin/nc -l 9282
root 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}

systemd管理服务的更多相关文章

  1. linux任务计划 chkconfig工具 systemd管理服务 unit介绍 target介绍

    linux任务计划 任务计划:特定时间备份数据,重启服务,shell脚本,单独的命令等等. 任务计划配置文件:cat /etc/crontab [root@centos7 ~]# cat /etc/c ...

  2. linux任务计划cron、chkconfig工具、systemd管理服务、unit和target介绍

    第8周第1次课(5月14日) 课程内容: 10.23 linux任务计划cron10.24 chkconfig工具10.25 systemd管理服务10.26 unit介绍10.27 target介绍 ...

  3. Linux centos7 linux任务计划cron、chkconfig工具、systemd管理服务、unit介绍、 target介绍

    一.linux任务计划cron crontab -u  -e -l -r 格式;分 时 日 月 周 user command 文件/var/spool/corn/username 分范围0-59,时范 ...

  4. [CoreOS 转载] CoreOS实践指南(七):Docker容器管理服务

    转载:http://www.csdn.net/article/2015-02-11/2823925 摘要:当Docker还名不见经传的时候,CoreOS创始人Alex就预见了这个项目的价值,并将其做为 ...

  5. systemd 编写服务管理脚本

    我们运行 linux 服务器的主要目的是通过运行程序提供服务,比如 mysql.web server等.因此管理 linux 服务器主要工作就是配置并管理上面运行的各种服务程序.在 linux 系统中 ...

  6. systemd 编写服务管理脚本---学习

    转载:https://www.cnblogs.com/sparkdev/p/8521812.html 我们运行 linux 服务器的主要目的是通过运行程序提供服务,比如 mysql.web serve ...

  7. [转贴]systemd 编写服务管理脚本

    [转贴]sparkdev大神的博客, 关于 systemd的配置文件的 介绍, 自己之前二进制安装 k8s 时 超过一个 service文件 但是当时不明不白的. 现在再学习一下大神的文章 的确牛B ...

  8. Linux 使用 Systemd 管理进程服务

    转载自:https://mp.weixin.qq.com/s/e-_PUNolUm22-Uy_ZjpuEA systemd 介绍 systemd是目前Linux系统上主要的系统守护进程管理工具,由于i ...

  9. CentOs7下systemd管理知识要点

    centOs7的一个巨大的变动就是用systemd取代了原来的System V init.systemd是一个完整的软件包,安装完成后有很多物理文件组成,大致分布为,配置文件位于/etc/system ...

随机推荐

  1. 控制台API函数----HANDLE、SetConsoleCursorPosition、SetConsoleTextAttribute

    控制台API函数 调用相关文本界面控制的API函数,这些函数可分为三类. 一.用于控制台窗口控制的函数(包括窗口的缓冲区大小.窗口前景字符和背景颜色.窗口标题.大小和位置等): 二.用于控制台输入输出 ...

  2. JSX 和 template 随想

    就目前而言,我用到的前端页面开发框架主要有两种:以JSX为主的react和以template为主的vue. 虽然这两种方式各有千秋,但我其实更偏爱template多一些.为什么? 相较于灵活的JSX, ...

  3. java项目配置域名(tomcat直接配置 or 使用nginx反向代理)

    一:  tomcat直接配置域名:https://blog.csdn.net/qq_36330228/article/details/78516160 二: 使用nginx进行反向代理 tomcat服 ...

  4. socket http tcp udp ip 协议

    Socket可以支持不同的传输层协议(TCP或UDP),当使用TCP协议进行连接时,该Socket连接就是一个TCP连接. socket是在应用层和传输层之间的一个抽象层,它把TCP/IP层复杂的操作 ...

  5. Linux下ps -ef 和 ps aux的区别

    Linux下显示系统进程的命令ps,最常用的有ps -ef 和ps aux.这两个到底有什么区别呢?两者没太大差别,讨论这个问题,要追溯到Unix系统中的两种风格,System V风格和BSD 风格, ...

  6. 在matlab中实现线性回归和logistic回归

    本文主要讲解在matlab中实现Linear Regression和Logistic Regression的代码,并不涉及公式推导.具体的计算公式和推导,相关的机器学习文章和视频一大堆,推荐看Andr ...

  7. (转)python通过paramiko实现,ssh功能

    python通过paramiko实现,ssh功能 1 import paramiko 2 3 ssh =paramiko.SSHClient()#创建一个SSH连接对象 4 ssh.set_missi ...

  8. nginx配置文件nginx.conf 不包括server节点

    整理的一个nginx.conf的配置,不包括server节点介绍 原文请查看,Nginx配置文件(nginx.conf)配置详解 # For more information on configura ...

  9. Python中bisect的使用

    在<Think Python>中第十章的练习中,涉及到了分半查找的bisect模块.为此,在网上查阅了Python中bisect模块的相关内容.有几个链接相对权威和明白: 1> ht ...

  10. MySQL 50条必练查询语句

    Student(S#,Sname,Sage,Ssex) 学生表 Course(C#,Cname,T#) 课程表 SC(S#,C#,score) 成绩表 Teacher(T#,Tname) 教师表 #- ...