Adding a Custom systemd Service¶
How to define, install, enable, and debug a custom systemd service.
This English edition keeps the original illustrations and reproducible command or configuration examples.



Commands and configuration¶
[Unit]
Description=Hywelstar Demo Service
After=network.target
[Service]
ExecStart=/home/root/hywelstar_script.sh
Restart=on-failure
[Install]
WantedBy=multi-user.target
● hywelstar_service.service - Hywelstar Demo Service
Loaded: loaded (/etc/systemd/system/hywelstar_service.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Fri 2021-09-24 01:40:47 UTC; 1min 8s ago
Process: 9820 ExecStart=/home/root/hywelstar_script.sh (code=exited, status=0/SUCCESS)
Main PID: 9820 (code=exited, status=0/SUCCESS)
Sep 24 01:40:47 UserDevice systemd[1]: Started Hywelstar Demo Service.
Sep 24 01:40:47 UserDevice hywelstar_script.sh[9820]: Hello, I am Hywelstar, This is a demo!
Practical notes¶
Test each change on a recoverable target, keep logs from the boot or failure path, and record the exact kernel and userspace versions used in the result.