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 ...
随机推荐
- 使用git往gitee传数据时pull命令的使用
按‘i’进入编辑模式------->写入内容------>按Esc键退出-------->在左下角的冒号后面输入‘wq’,表示退出并保存
- linux下configure,make,make install的意义
tar.gz.tar.bz2的是源代码包,需要编译之后才能安装,在编译过程中你可以指定各种参数以适应你的系统需求,比如安装位置,优化参数,要哪些功能不要哪些功能等等.这类源代码包需要解压后(tar.g ...
- SpringBoot---静态页面加载
Thymeleaf模板配置: maven添加支持如下: <dependency> <groupId>org.springframework.boot</groupId&g ...
- 给linux系统配置网络
修改/etc/sysconfig/network-scripts/ifcfg-eth0 ip地址变量:IPADDR子网掩码变量:NETMASK如果本机和linux 网段不相同 如:192.168.8. ...
- 团队项目alpha冲刺
Deadline: 2018-11-18 22:00PM,以博客提交至班级博客时间为准 提交: (a) 项目课堂演示: (b) 7篇冲刺随笔,组内可共享: (c) 1篇测试随笔,组内可共享: (d) ...
- [牛客小白月赛4 H] 相邻的糖果
Description 有n个盒子摆成一排,每个盒子内都有ai个糖果. 现在你可以执行以下操作: ·你可以选择任意一个盒子,在选择的盒子内吃掉一个糖果. 对你的要求如下: ·任何m个相邻的盒子内糖果数 ...
- 记一次安装Nginx+php-fpm安装后无法解析.php文件,状态码200,但显示空白页
安装环境: Nginx:Nginx1.12.2 PHP:PHP 7.2 系统:CentOS 7.4 安装方式: Nginx与PHP都是yum安装的,具体步骤: 1.安装epel源再安装Nginx: r ...
- JavaScript之破解数独(附详细代码)
在上一篇分享中,我们用Python和Django来破解数独,这对不熟悉Python和Django的人来说是非常不友好的.这次,笔者只用HTML和JavaScript写了破解数独的程序,对于熟悉前端 ...
- Windows Server 2008 R2 如何关闭防火墙
1. 打开 [控制面板],选择 - [检查防火墙状态] 2. Windows防火墙窗口界面,选择 – [高级设置] 3. 选择– [windows防火墙属性] 4.在[域配置文件], ...
- c# 数字之间的计算
1.c# 65*1.0F/102=0.637254901960784 2.mysql TRUNCATE(65/102,9) 9代表的是保留几位小数 3.多张表关联,修改某张表的字段 UPDATE s ...