Set the startup script on Linux (RasPi, Edison)

I wanted Node.js to start automatically when Edison started.

Startup script settings

Create a startup script unit

First, create a configuration file

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

Script setting example (for Node.js)

Contents of the configuration file

[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

Start the script

$ systemctl start hoge.service

Stop the script

$ systemctl stop hoge.service

View log

$ systemctl status hoge.service

Enable startup script

Automatically start when the OS starts

$ systemctl enable hoge.service

Disable startup script

Do not start automatically when the OS starts

$ systemctl disable hoge.service

Reference site

http://enakai00.hatenablog.com/entry/20130917/1379374797

Recommended Posts

Set the startup script on Linux (RasPi, Edison)
Install the JDK on Linux
Paste the link on linux
Run cron on Amazon Linux (set on Linux)
Set the environment variable PYTHONPATH on zsh
Notes on using OpenCL on Linux on the RX6800
On Ubuntu Linux, set Tab to q
Compiling the Linux kernel (Linux 5.x on Ubuntu 20.04)
On Linux (Ubuntu), tune the Trackpad and set the function to a three-finger swipe
Set up golang with goenv on GNU / Linux
[2020July] Check the UDID of the iPad on Linux
Set a fixed IP in the Linux environment
Set up an Objective-C 2.0 development environment on Linux
Geolocation on Intel Edison
Push notification to Intel Edison
Debian Intel Edison and put scikit-learn
Infrared remote control reception with Intel Edison
Django startup
Control LED bulbs from a microcomputer (Intel Edison) (1)
Control LED bulbs from a microcomputer (Intel Edison) (2)
Set the startup script on Linux (RasPi, Edison)
Specify the volume on linux and make a sound
Create a QR code for the URL on Linux
[AWS CLI] Enable the AWS CLI on Red Hat Enterprise Linux 8
Enable zfs on the Springdale Linux 8.3 installation ISO image
[Part 1] Let's set up a Minecraft server on Linux
Check if the LAN cable is disconnected on Linux
About the --enable-shared option when building Python on Linux
Mounting samba on Linux. Until it mounts at startup.
I tried installing the Linux kernel on virtualbox + vagrant
Announcing the availability of Java 11 LTS on Amazon Linux 2