systemd 和 如何修改和创建一个 systemd service (Understanding and administering systemd)
系统中经常会使用到 systemctl 去管理systemd程序,刚刚看了一篇关于 systemd 和 SysV 相关的文章,这里简要记录一下:
systemd定义: (英文来解释更为原汁原味)
systemd is a system and service manager for Linux, compatible with SysV and LSB init scripts. systemd provides:
Aggressive parallelization capabilities
Uses socket and D-Bus activation for starting services
Offers on-demand starting of daemons, keeps track of processes using Linux cgroups
Supports snapshotting and restoring of the system state
Maintains mount and automount points
Implements an elaborate transactional dependency-based service control logic.
The systemctl command is the primary tool to manage systemd. It combines the functionality of SysVinit’s service and chkconfig commands into a single tool you can use to enable and disable services permanently or only for the current session.
systemd manages units, which are representations of system resources and services. This following list shows the unit types that systemd can manage:
- service
-
A service on the system, including instructions for starting, restarting, and stopping the service.
- socket
-
A network socket associated with a service.
- device
-
A device specifically managed with systemd.
- mount
-
A mountpoint managed with systemd.
- automount
-
A mountpoint automatically mounted on boot.
- swap
-
Swap space on the system.
- target
-
A synchronization point for other units. Usually used to start enabled services on boot.
- path
-
A path for path-based activation. For example, you can start services based on the state of a certain path, such as whether it exists or not.
- timer
-
A timer to schedule activation of another unit.
- snapshot
-
A snapshot of the current systemd state. Usually used to rollback after making temporary changes to systemd.
- slice
-
Restrivtion of resources through Linux Control Group nodes (cgroups).
- scope
-
Information from systemd bus interfaces. Usually used to manage external system processes.
systemctl 常用管理命令:
# systemctl start foo
# systemctl stop foo
# systemctl restart foo
# systemctl status foo
# systemctl enable foo
# systemctl disable foo
# systemctl mask foo
# systemctl is-enabled foo
systemctl service 创建:
systemctl service在两个目录中: /etc/systemd/system 和 /usr/lib/systemd/system 之中
我们一般自己创建的service 直接放在 /etc/systemd/system 之中即可:
vim xuyaowen.service 创建文件
输入如下内容:
[Unit]
Description=xuyaowen custom service
Requires=network.target [Service]
Type=simple
ExecStart=/usr/bin/sleep infinity [Install]
WantedBy=multi-user.target
保存退出后,使用 systemctl start xuyaowen 启动后,使用 systemctl status 查看service 状态:
➜ system systemctl status xuyaowen.service
● xuyaowen.service - xuyaowen custom service
Loaded: loaded (/etc/systemd/system/xuyaowen.service; disabled; vendor preset: disabled)
Active: active (running) since Thu -- :: CST; 38min ago
Main PID: (sleep)
Tasks: (limit: )
Memory: .0K
CGroup: /system.slice/xuyaowen.service
└─ /usr/bin/sleep infinity Aug :: yaowenxu systemd[]: Started xuyaowen custom service.
service 创建成功。具体systemd 与 SysV 之间的关系可以在网络上较为容易查找到,我这里只是作为简要记录。关于systemd 更为详细的内容,请参考fedora doc .
保持更新,转载请注明出处。如果您觉得本文对你有帮助请点右下角推荐,谢谢
systemd 和 如何修改和创建一个 systemd service (Understanding and administering systemd)的更多相关文章
- C#创建一个Windows Service
Windows Service这一块并不复杂,但是注意事项太多了,网上资料也很凌乱,偶尔自己写也会丢三落四的.所以本文也就产生了,本文不会写复杂的东西,完全以基础应用的需求来写,所以不会对Window ...
- Step by Step 创建一个WCF Service
原创地址:http://www.cnblogs.com/jfzhu/p/4025448.html 转载请注明出处 (一)创建WCF Service (1)创建WCF Service类库 创建一个Cla ...
- Step by Step 创建一个 Web Service
原创地址:http://www.cnblogs.com/jfzhu/p/4022139.html 转载请注明出处 (一)创建Web Service 创建第一个项目,类型选择ASP.NET Empty ...
- 转载——Step by Step 创建一个 Web Service
原创地址:http://www.cnblogs.com/jfzhu/p/4022139.html 转载请注明出处 (一)创建Web Service 创建第一个项目,类型选择ASP.NET Empty ...
- 如何在Kubernetes里创建一个Nginx service
Jerry之前的文章如何在Kubernetes里创建一个Nginx应用,已经使用kubectl命令行创建了Pod,但是在kubernetes中,Pod的IP地址会随着Pod的重启而变化,因此用Pod的 ...
- 使用Windows Service Wrapper快速创建一个Windows Service
前言 今天介绍一个小工具的使用.我们都知道Windows Service是一种特殊的应用程序,它的好处是可以一直在后台运行,相对来说,比较适合一些需要一直运行同时不需要过多用户干预的应用程序,这一类我 ...
- 使用Windows Service Wrapper快速创建一个Windows Service 如nginx
前言 今天介绍一个小工具的使用.我们都知道Windows Service是一种特殊的应用程序,它的好处是可以一直在后台运行,相对来说,比较适合一些需要一直运行同时不需要过多用户干预的应用程序,这一类我 ...
- 创建一个Windows Service 程序
1.新建Windows项目,选择"Windows服务"类型的项目. 2.在生成的Service1.cs中代码中写你需要的代码,如下: using System; using Sys ...
- 如何创建一个AJAX-Enabled WCF Service
原创地址:http://www.cnblogs.com/jfzhu/p/4041638.html 转载请注明出处 前面的文章中介绍过<Step by Step 创建一个WCF Servi ...
随机推荐
- Django --需求文件requirements.txt
在虚拟环境中使用pip生成: (venv) $ pip freeze >requirements.txt 当需要创建这个虚拟环境的完全副本,可以创建一个新的虚拟环境,并在其上运行以下命令: (v ...
- 高德地图添加marker及反地理编码获取POI
项目中集成百度.高德.腾讯地图已是司空见惯的事情,今天我总结了一下项目中用到的高德地图常用的功能: 1.展示高德地图并定位显示定位图标: 2.添加实时大头针: 3.反地理编码获取周围兴趣点 效果如下: ...
- 从零开始学 Web 之 BOM(一)BOM的概念,一些BOM对象
大家好,这里是「 从零开始学 Web 系列教程 」,并在下列地址同步更新...... +-------------------------------------------------------- ...
- 常见注入手法第四讲,SetWindowsHookEx全局钩子注入.以及注入QQ32位实战.
常见注入手法第四讲,SetWindowsHookEx全局钩子注入.以及注入QQ32位实战. PS:上面是操作.最后是原理 一丶需要了解的API 使用全局钩子注入.我们需要了解几个WindowsAPI. ...
- 如何自定义CSS滚动条的样式?
欢迎大家前往腾讯云+社区,获取更多腾讯海量技术实践干货哦~ 本文由前端林子发表 本文会介绍CSS滚动条选择器,并在demo中展示如何在Webkit内核浏览器和IE浏览器中,自定义一个横向以及一个纵向的 ...
- 怎么样在windows命令下创建一个没有文件名的文件?
直接上图 echo ' ' >> .aa //创建一个空字符的 .aa 的文件
- pycharm专业版破解
网上找的用license server破解的地址都不可用== 有个方法倒是靠谱的,记录一下: 1.将C:\Windows\System32\drivers\etc里面的hosts文件打开,然后在文件中 ...
- Deep learning with Python 学习笔记(8)
Keras 函数式编程 利用 Keras 函数式 API,你可以构建类图(graph-like)模型.在不同的输入之间共享某一层,并且还可以像使用 Python 函数一样使用 Keras 模型.Ker ...
- [JSOI2010] 连通数
Description Input 输入数据第一行是图顶点的数量,一个正整数N. 接下来N行,每行N个字符.第i行第j列的1表示顶点i到j有边,0则表示无边. Output 输出一行一个整数,表示该图 ...
- SPI Flash(W25Q16DV) 驱动
大体上可分为以下几个部分: 1.注册设备驱动 spi_register_driver 2.分配 mtd_info 结构体 3.配置 mtd_info 结构体 4.注册 mtd_info 结构体 构建 ...