0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Linux(RasPi,Edison)で起動スクリプトを設定する

Last updated at Posted at 2020-06-01

Edison起動時にNode.jsを自動起動させたかった.

起動スクリプトの設定

起動スクリプトのユニット作成

まずは設定ファイルを作る

$ vi /etc/systemd/system/hoge.service 

スクリプトの設定例 (Node.jsの場合)

設定ファイルの中身

[Unit]
Description=Node.js Hoge-Server

[Service]
WorkingDirectory=/home/root/Documents/Project/hoge
Type=simple
ExecStart=/usr/bin/node app.js
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=node-server

[Install]
WantedBy=multi-user.target

スクリプトを開始する

$ systemctl start hoge.service

スクリプトを停止する

$ systemctl stop hoge.service

ログを見る

$ systemctl status hoge.service

起動スクリプトのイネーブル

OS起動時に自動起動させる

$ systemctl enable hoge.service

起動スクリプトのディセーブル

OS起動時に自動起動させない

$ systemctl disable hoge.service

参考サイト

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?