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 ...
随机推荐
- Python中通过threshold创建mask
[code] import numpy as np threshold=2 a=np.array([[1,2,3],[3,4,5]]) b=a>threshold print("a=& ...
- c++11并行、并发与多线程编程
首先,我们先理解并发和并行的区别. 你吃饭吃到一半,电话来了,你一直到吃完了以后才去接,这就说明你不支持并发也不支持并行. 你吃饭吃到一半,电话来了,你停了下来接了电话,接完后继续吃饭,这说明你支持并 ...
- Spring Boot之JdbcTemplate多数据源配置与使用
之前在介绍使用JdbcTemplate和Spring-data-jpa时,都使用了单数据源.在单数据源的情况下,Spring Boot的配置非常简单,只需要在application.propertie ...
- 从零开始学 Web 之 HTML5(一)HTML5概述,语义化标签
大家好,这里是「 从零开始学 Web 系列教程 」,并在下列地址同步更新...... github:https://github.com/Daotin/Web 微信公众号:Web前端之巅 博客园:ht ...
- Spring Boot + Spring Cloud 实现权限管理系统 后端篇(二十):服务熔断(Hystrix、Turbine)
在线演示 演示地址:http://139.196.87.48:9002/kitty 用户名:admin 密码:admin 雪崩效应 在微服务架构中,由于服务众多,通常会涉及多个服务层级的调用,而一旦基 ...
- Quartz.NET的简单任务管理类
昨天使用Quartz.NET做了个定时任务的功能,并实现了多个定时任务的功能 下面这个类实现了如下功能: 1.对定时任务进行管理 2.创建定时任务,需要给定时任务一个job的名称 3.判断给定的job ...
- VUE + ElementUI 从搭建到运行
版权声明:本文为博主原创文章,欢迎转载,转载请注明作者.原文超链接 前言:本文简洁的描述VUE + ElementUI 从搭建到运行,可以根据本文先搭建出可运行的项目,然后再详细回顾每个步骤所做的事: ...
- 你不知道的Linux(持续更新中)
1.关于GNU.Linux.GNU/Linux三者的关系 GNU 项目创始于一九八四年,旨在开发一个类似 Unix ,且为自由软件的完整的操作系统: GNU 系统.(也可把GNU看成一个自由软件工程) ...
- 在C#中,如何连接已加密的Sqlite数据库
对数据加密分两种,一种是对数据库本身进行加密,另一种是对数据表中的数据进行加密, 如果SQLite数据库加密,我这里使用的一个管理工具叫SQLiteDeveloper,如下就可以加密数据库 , 如果在 ...
- asp.net前台页面与后台之间传值,
在前台用 js 获取到的 “值 ”需要传到后台,在后台调用, ****** 原有传入的 “值 ” 不要被覆盖 1.最简单的在页面写一个隐藏表单,隐藏标签,把获取到的值赋给隐藏标签之后 ...