This document contains the content of /resources/docs/text/systemd_autostart_example.txt. Download the file by setting the ?act=download parameter, or access the raw file at either srcs.cc or src.cerium.cc.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# This is a simple example for creating a systemd service which runs an executable after system startup and restarts unless stopped.
cat > /etc/systemd/system/example.service << EOF
[Unit]
Description=An example service
After=network.target
[Service]
ExecStart=/home/user/script.sh
Restart=always
[Install]
WantedBy=multi-user.target
EOF
systemctl enable example.service
systemctl start example.service
# Use 'journalctl -u example.service' to view the service logs,
# or view the status and other information with 'systemctl status example.service'
More resources