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 ...
随机推荐
- CSS--最最最基础操作
CSS 规则由两个主要的部分构成:选择器,以及一条或多条声明. h1 {color:red; font-size:14px;} css的四种引入方式 1.行内式 行内式是在标记的style属性中设定 ...
- WebView使用_WebView监听网页下载_DownloadManager使用
最近在做一个较简单的项目:通过一个webview来显示一个网页的App 这个网页有下载的功能,关于这一功能需要用到两个知识点: 1.webview监听网页的下载链接.(webview默认情况下是没有开 ...
- SSH, 整合分页功能,连带DAO经典封装
任何一个封装讲究的是,使用,多状态.Action: 任何一个Action继承分页有关参数类PageManage,自然考虑的到分页效果,我们必须定义下几个分页的参数.并根据这个参数进行查值. 然 ...
- Golang 协程调度
一.线程模型 N:1模型,N个用户空间线程在1个内核空间线程上运行.优势是上下文切换非常快但是无法利用多核系统的优点. 1:1模型,1个内核空间线程运行一个用户空间线程.这种充分利用了多核系统的优势但 ...
- sip (db33)信令交互-视频点播与回播
请求视频流: INVITE sip:@ SIP/2.0 Via: SIP/;rport;branch=z9hG4bK178329191 From: <sip:@>;tag= To: < ...
- FFmpeg数据结构AVPacket
本文为作者原创,转载请注明出处:https://www.cnblogs.com/leisure_chn/p/10410320.html 本文基于FFmpeg 4.1版本. 1. 数据结构定义 stru ...
- Java 使用 happen-before 规则实现共享变量的同步操作
前言 熟悉 Java 并发编程的都知道,JMM(Java 内存模型) 中的 happen-before(简称 hb)规则,该规则定义了 Java 多线程操作的有序性和可见性,防止了编译器重排序对程序结 ...
- Oracle入门《Oracle介绍》第一章1-1
1.Oracle 简介 a.对象关系型的数据库管理系统 (ORDBMS) b.在管理信息系统.企业数据处理.因特网及电子商务等领域使用非常广泛 c.在数据安全性与数据完整性控制方面性能优越 d.跨操作 ...
- SqlServer--用代码创建和删除数据库和表
创建数据库,创建表,设置主键数据库的分离和附加MS SQLServer的每个数据库包含:1个主数据文件(.mdf)必须.1个事务日志文件(.ldf)必须.可以包含:任意多个次要数据文件(.ndf)多个 ...
- Python 实现的 12306抢票脚本
Python12306抢票脚本 本脚本使用一个类来实现所有代码,大体上分为以下几个模块及其步骤:- 初始化对象属性(在抢票前进行的属性初始化,包括初始化浏览器模拟对象,个人信息等).- 建立模拟浏览器 ...