---
title: "Linux systemd 中 service的使用"
author: "codyJava"
date: "2015-05-15T15:32:45Z"
tags: []
categories: ["操作系统"]
slug: "linux-systemd-service"
draft: false
lastmod: "2015-05-22T23:06:34Z"
id: 2211547
url: "https://codyjava.iteye.com/blog/2211547"
---

运行命令systemctl start /usr/lib/systemd/system/test.service 去启动一个service，遇到如下错误：

 

Failed to issue method call: Unit usr-lib-systemd-system\\x2d\\x2dtest.service.mount failed to load: No such file or directory.

 

原因：

如果unit的名字以 ‘/’ 开头，就会被systemd认为是一个mount，而不是service，所以，在这里不能用path来运行一个service。

来源：https://bbs.archlinux.org/viewtopic.php?id=156616

 

解决：

systemctl start test.service

 

关于rpmbuild里spec中调用systemd的宏变量可以参考下面的link：

http://cgit.freedesktop.org/systemd/systemd/tree/src/core/macros.systemd.in

 

对于systemd中，命令参数的介绍：

http://www.ebugg-i.com/technology/linux/what-is-systemctl-linux-command.html

 

对于systemd的入门介绍：

https://wiki.merproject.org/wiki/Systemd

 

对于systemd的运行机制：

http://www.cnblogs.com/cfox/archive/2013/02/01/2888759.html