About Systemd
Refer to Ruan Yifeng’s blog post: “Systemd Tutorial: Commands”
Link: http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-commands.html
Cheat Sheet for Unit Configuration
- Create a
xxx.servicefile under/etc/systemd/system/
vim /etc/systemd/system/xxx.service- A simple template for xxx.service content, where
ExecStartshould point to the actual executable or program launch command:
[Unit]Description=xxxDocumentation=https://github.com/xxxx/xxxxWants=network.targetAfter=network.target
[Service]Type=simpleDynamicUser=yesExecStart=/path/to/your/app/execRestart=alwaysRestartSec=3
[Install]WantedBy=multi-user.target- Register and use:
# Load the xxx servicesystemctl daemon-reload# Enable xxx to start on bootsystemctl enable xxx.service# Check xxx statussystemctl status xxx.service# Start xxxsystemctl start xxx.service# Restart xxxsystemctl restart xxx.service# Stop xxxsystemctl stop xxx.service