【Raspberry Pi】自動実行の登録方法

Raspberry Pi(というか、raspbian-OS)で自動実行はchkconfigで実施可能です。

デフォルトで入ってた気もするけど、入ってなければ入れます。

$sudo apt-get update

$sudo apt-get install chkconfig

 

chkconfigを実行。事前に/etc/init.dに作ったシェルなりを入れておきます。無論、権限は変更しておきます。

$sudo chmod 755 xxx.sh
$sudo chown root xxx.sh
$sudo chgrp root xxx.sh
$sudo mv xxx.sh /etc/init.d
$cd /etc/init.d/ ←移動する必要ないかも


$sudo chkconfig xxx.sh on

登録されているかは、以下のコマンドで確認可能。

 $sudo chkconfig xxx.sh --list

xxx.sh               0:off  1:off  2:on 3:on 4:on 5:on 6:off

すべて表示するなら、

$sudo chkconfig --list

を実施。