Systemd:修订间差异

来自Gea-Suan Lin's Wiki
跳到导航 跳到搜索
此页面具有访问限制。如果您看见此消息,则说明您没有权限访问此页面。
第1行: 第1行:
{{Lowercase}}
{{Lowercase}}
'''systemd'''是一個系統套件。
'''systemd'''是一個系統套件。
== 設定 ==
system模式下不需要額外設定就可以用,建議將自製的service檔案裝到<code>/etc/systemd/system</code>下;user模式下需要針對特定使用者啟動systemd:
<syntaxhighlight lang="bash">
sudo loginctl enable-linger foo
</syntaxhighlight>
另外在<code>.profile</code>內可能會需要指定<code>XDG_RUNTIME_DIR</code>:
<syntaxhighlight lang="bash">
export XDG_RUNTIME_DIR=/run/user/$(id -u)
</syntaxhighlight>


== 範例 ==
== 範例 ==

2023年10月7日 (六) 05:09的版本

systemd是一個系統套件。

設定

system模式下不需要額外設定就可以用,建議將自製的service檔案裝到/etc/systemd/system下;user模式下需要針對特定使用者啟動systemd:

sudo loginctl enable-linger foo

另外在.profile內可能會需要指定XDG_RUNTIME_DIR

export XDG_RUNTIME_DIR=/run/user/$(id -u)

範例

這是一個很簡單的範例,放在/etc/systemd/system/下:

#
[Unit]
Description=Description
After=remote-fs.target

[Service]
ExecStart=/usr/bin/spawn-fcgi
Restart=on-failure
RestartSec=60
Type=simple

[Install]
WantedBy=multi-user.target

這是user模式下的(因為user模式下沒有multi-user.target,也不需要remote-fs.target),放在~/.config/systemd/user/下:

#
[Unit]
Description=Description

[Service]
ExecStart=/usr/bin/spawn-fcgi
Restart=on-failure
RestartSec=60
Type=simple

[Install]
WantedBy=default.target

外部連結