両方とも前のリビジョン 前のリビジョン 次のリビジョン 前のリビジョン linux:commands:service [2013/10/04 02:26] – [サービス一覧表示] ともやん linux:commands:service [2025/04/19 15:36] (現在) – [シャットダウン、サスペンド、休止状態] ともやん
===== サービス起動 ===== ===== サービス起動 =====
<code > Fedora
$ sudo service httpd start <WRAP color_term >
</code > <WRAP color_command><html><pre>
<font color="#0087FF"><b> $</b></font> <font color="#26A269"><u style="text-decoration-style:solid"> sudo</u></font> <font color="#26A269">systemctl</font> start httpd.service
</pre></html></WRAP>
</WRAP>
<WRAP color_term>
<WRAP color_command><html><pre>
<font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">systemctl</font> start <font color="#2A7BDE"><b>{</b></font>httpd,php-fpm<font color="#2A7BDE"><b>}</b></font>
</pre></html></WRAP>
</WRAP >
Fedora 15 以降 CentOS 6
<code > <WRAP color_term >
$ sudo systemctl start httpd. service <WRAP color_command><html><pre>
</code > <font color="#0087FF"><b> $</b></font> <font color="#26A269"><u style="text-decoration-style:solid"> sudo</u></font> <font color="#26A269"> service</font> httpd start
</pre></html></WRAP>
</WRAP >
===== サービス停止 ===== ===== サービス停止 =====
<code > Fedora
$ sudo service httpd stop <WRAP color_term >
</code > <WRAP color_command><html><pre>
<font color="#0087FF"><b> $</b></font> <font color="#26A269"><u style="text-decoration-style:solid"> sudo</u></font> <font color="#26A269">systemctl</font> stop httpd.service
</pre></html></WRAP>
</WRAP>
<WRAP color_term>
<WRAP color_command><html><pre>
<font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">systemctl</font> stop <font color="#2A7BDE"><b>{</b></font>httpd,php-fpm<font color="#2A7BDE"><b>}</b></font>
</pre></html></WRAP>
</WRAP >
Fedora 15 以降 CentOS 6
<code > <WRAP color_term >
$ sudo systemctl stop httpd. service <WRAP color_command><html><pre>
</code > <font color="#0087FF"><b> $</b></font> <font color="#26A269"><u style="text-decoration-style:solid"> sudo</u></font> <font color="#26A269"> service</font> httpd stop
</pre></html></WRAP>
</WRAP >
===== サービス再起動 ===== ===== サービス再起動 =====
stop & start を実行する。 Fedora
<code > <WRAP color_term >
$ sudo service httpd restart <WRAP color_command><html><pre>
</code > <font color="#0087FF"><b> $</b></font> <font color="#26A269"><u style="text-decoration-style:solid"> sudo</u></font> <font color="#26A269">systemctl</font> restart httpd.service
</pre></html></WRAP>
</WRAP>
<WRAP color_term>
<WRAP color_command><html><pre>
<font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">systemctl</font> restart <font color="#2A7BDE"><b>{</b></font>httpd,php-fpm<font color="#2A7BDE"><b>}</b></font>
</pre></html></WRAP>
</WRAP >
Fedora 15 以降 CentOS 6
<code > <WRAP color_term >
$ sudo systemctl restart httpd. service <WRAP color_command><html><pre>
</code > <font color="#0087FF"><b> $</b></font> <font color="#26A269"><u style="text-decoration-style:solid"> sudo</u></font> <font color="#26A269"> service</font> httpd restart
</pre></html></WRAP>
</WRAP >
===== サービス設定反映 ===== ===== サービス設定反映 =====
サービスにHUPシグナルを送って設定を反映させる。 Fedora
<code > <WRAP color_term>
$ sudo service httpd reload <WRAP color_command><html><pre>
</code > <font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">systemctl</font> reload httpd.service
</pre></html></WRAP>
Fedora 15 以降 </WRAP>
<code > サービスにHUPシグナルを送って設定を反映させる。\\
$ sudo systemctl reload httpd.service \\
</code > CentOS 6
<WRAP color_term >
<WRAP color_command><html><pre>
<font color="#0087FF"><b> $</b></font> <font color="#26A269"><u style="text-decoration-style:solid"> sudo</u></font> <font color="#26A269"> service</font> httpd reload
</pre ></html></WRAP >
</WRAP >
===== サービス自動起動設定 ===== ===== サービス自動起動設定 =====
<code > Fedora
$ sudo chkconfig httpd on <WRAP color_term >
</code > <WRAP color_command><html><pre>
<font color="#0087FF"><b> $</b></font> <font color="#26A269"><u style="text-decoration-style:solid"> sudo</u></font> <font color="#26A269">systemctl</font> enable httpd.service
</pre></html></WRAP>
</WRAP>
<WRAP color_term>
<WRAP color_command><html><pre>
<font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">systemctl</font> enable <font color="#A347BA">--now</font> httpd
</pre></html></WRAP>
</WRAP >
Fedora 15 以降 CentOS 6
<code > <WRAP color_term >
$ sudo systemctl enable httpd.service <WRAP color_command><html><pre>
</code > <font color="#0087FF"><b> $</b></font> <font color="#26A269"><u style="text-decoration-style:solid"> sudo</u></font> <font color="#26A269">chkconfig</font> httpd on
</pre></html></WRAP>
</WRAP >
===== サービス自動起動無効設定 ===== ===== サービス自動起動無効設定 =====
<code > Fedora
$ sudo chkconfig httpd off <WRAP color_term >
</code > <WRAP color_command><html><pre>
<font color="#0087FF"><b> $</b></font> <font color="#26A269"><u style="text-decoration-style:solid"> sudo</u></font> <font color="#26A269">systemctl</font> disable httpd.service
</pre></html></WRAP>
</WRAP >
Fedora 15 以降 CentOS 6
<code > <WRAP color_term >
$ sudo systemctl disable httpd.service <WRAP color_command><html><pre>
</code > <font color="#0087FF"><b> $</b></font> <font color="#26A269"><u style="text-decoration-style:solid"> sudo</u></font> <font color="#26A269">chkconfig</font> httpd off
</pre></html></WRAP>
</WRAP>
===== サービス状態表示 =====
Fedora
<WRAP color_term>
<WRAP color_command><html><pre>
<font color="#0087FF"><b>$</b></font> <font color="#26A269"> systemctl</font> status acpid
</pre></html></WRAP>
</WRAP>
<WRAP color_term>
<WRAP color_command><html><pre>
<font color="#0087FF"><b>$</b></font> <font color="#26A269">systemctl</font> status <font color="#2A7BDE"><b>{</b></font> httpd,php-fpm<font color="#2A7BDE"><b>}</b></font>
</pre></html></WRAP>
</WRAP >
===== サービス一覧表示 ===== ===== サービス一覧表示 =====
<code > Fedora
$ chkconfig --list <WRAP color_term >
</code > <WRAP color_command><html><pre>
<font color="#0087FF"><b> $</b></font> <font color="#26A269">systemctl</font> <font color="#A347BA"> -t</font> service <font color="#A347BA"> --all</font>
</pre></html></WRAP>
</WRAP >
Fedora 15 以降 CentOS 6
<code > <WRAP color_term >
$ systemctl -t service --all <WRAP color_command><html><pre>
</code > <font color="#0087FF"><b> $</b></font> <font color="#26A269">chkconfig</font> <font color="#A347BA"> --list</font>
</pre ></html></WRAP>
</WRAP>
===== systemd のランレベル設定方法 =====
[[linux:change_systemd_runlevel|systemd のランレベル設定方法]]\\
===== systemd のサービス定義ファイルの内容表示 ===== ===== systemd のサービス定義ファイルの内容表示 =====
<code > <WRAP color_term >
$ cat /usr/lib/systemd/system/named-chroot.service <WRAP color_command><html><pre>
</code > <font color="#0087FF"><b> $</b></font> <font color="#26A269"> cat</font> /usr/lib/systemd/system/named-chroot.service
</pre ></html></WRAP>
</WRAP>
===== シャットダウン、サスペンド、休止状態 =====
Fedora
<WRAP mintbl>
^ コマンド ^ 説明 ^
| <WRAP color_command><html><pre>
<font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">systemctl</font> <font color="#A347BA">--no-wall</font> reboot
</pre></html></WRAP> | システムを再起動する |
| <WRAP color_command><html><pre>
<font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">systemctl</font> poweroff</pre></html></WRAP> | システムの電源を切る |
| <WRAP color_command><html><pre>
<font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">systemctl</font> <font color="#A347BA">--no-wall</font> poweroff
</pre></html></WRAP> | システムの電源を切る (ログインユーザーに通知しない) |
| <WRAP color_command><html><pre>
<font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">shutdown</font> <font color="#A347BA">--poweroff</font> <a href="https://youtu.be/UhNDc-HwjFo?si=0l0YUuOn4zdYErlp">07:21</a>
</pre></html></WRAP> | システムの電源を切る (指定時間に) |
| <WRAP color_command><html><pre>
<font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">systemctl</font> suspend
</pre></html></WRAP> | システムをサスペンド(システム状態は RAM に保存)する |
| <WRAP color_command><html><pre>
<font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font><font color="#999999"> </font><font color="#26A269">systemctl</font> hibernate
</pre></html></WRAP> | システムをハイバネート(システム状態はディスクに保存)する |
| <WRAP color_command><html><pre>
<font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">systemctl</font> hybrid-sleep
</pre></html></WRAP> | システムをハイブリッドスリープ(システム状態は RAM とディスクに保存、一定期間でサスペンドからハイバネートへ移行)する |
| <WRAP color_command><html><pre>
<font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">systemctl</font> suspend-then-hibernate
</pre></html></WRAP> | |
| <WRAP color_command><html><pre>
<font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">systemctl</font> soft-reboot
</pre></html></WRAP> | |
| <WRAP color_command><html><pre><font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">shutdown</font> <font color="#A347BA">--halt</font> +3
</pre></html></WRAP>
| <WRAP color_command><html><pre>
<font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">shutdown</font> <font color="#A347BA">-c</font>
</pre></html></WRAP> | |
| <WRAP color_command><html><pre>
<font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">systemctl</font> halt
</pre></html></WRAP> | |
| <WRAP color_command><html><pre>
<font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">systemctl</font> reboot
</pre></html></WRAP> | |
</WRAP>
===== 参考文献 =====
[[https://community.nethserver.org/t/systemctl-and-vendor-preset-disabled/18355|Systemctl and "vendor preset: disabled" - Support - NethServer Community]]\\
[[https://www.freedesktop.org/software/systemd/man/systemd.preset.html|systemd.preset]]\\
[[rhdoc>ja/documentation/red_hat_enterprise_linux/7/html/system_administrators_guide/sect-managing_services_with_systemd-power#sect-Managing_Services_with_systemd-Power|10.4. システムのシャットダウン、サスペンド、および休止状態 | Red Hat Product Documentation]]\\
[[rhdoc>ja/documentation/red_hat_enterprise_linux/9/html/configuring_basic_system_settings/shutting-down-suspending-and-hibernating-the-system_managing-systemd#changing-the-power-button-behavior-in-gnome_changing-the-power-button-behavior|12.4. システムのシャットダウン、サスペンド、およびハイバネート | Red Hat Product Documentation]]\\
[[arc>Systemd#.E9.9B.BB.E6.BA.90.E7.AE.A1.E7.90.86|systemd - ArchWiki - systemd - ArchWiki]]\\
[[arc>%E9%9B%BB%E6%BA%90%E7%AE%A1%E7%90%86/%E3%82%B5%E3%82%B9%E3%83%9A%E3%83%B3%E3%83%89%E3%81%A8%E3%83%8F%E3%82%A4%E3%83%90%E3%83%8D%E3%83%BC%E3%83%88#.E9.AB.98.E3.83.AC.E3.83.99.E3.83.AB.E3.82.A4.E3.83.B3.E3.82.BF.E3.83.BC.E3.83.95.E3.82.A7.E3.82.A4.E3.82.B9_.28systemd.29|電源管理/サスペンドとハイバネート - ArchWiki]]\\