LoginSignup
5
8

More than 3 years have passed since last update.

電源ボタンで安全にシャットダウンさせる方法

Posted at

はじめに

Linuxを実機で動かしている時に、Windowsと同じように「電源ボタンをポチっと押しただけでシャットダウンできないか?」と思い立ち、ちょっと調べてみたら簡単に実現できることが分かりました。

この設定を活用すれば、ネットワーク周りの設定でミスした際に「モニターとキーボードを繋いで再起動」せずに済むので、覚えておくとちょっと便利かもしれません。

使用した環境

  • OS:CentOS 6.10

設定方法

  1. acpidという電源管理に関するパッケージをインストールします。
  2. /etc/acpi/events/power.confを編集して、「電源ボタンが押された際に、シャットダウンコマンドを実行する」と設定します。
  3. acpidの自動起動設定を済ませた後、acpidのサービスを起動して完了です。
[root@akagi ~]# yum install acpid

[root@akagi ~]# vi /etc/acpi/events/power.conf 
-------------------------------------------------------------
# ACPID config to power down machine if powerbutton is pressed, but only if
# no gnome-power-manager is running

event=button/power.*
#action=/etc/acpi/actions/power.sh
action=/sbin/shutdown -h now
-------------------------------------------------------------

[root@akagi ~]# chkconfig acpid on
[root@akagi ~]# service acpid start
5
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
8