| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 
 | # [required] 1. 创建可执行服务程序#
 DATE=`date '+%Y-%m-%d %H:%M:%S'`
 echo "Example service started at ${DATE}" | systemd-cat -p info
 
 while :
 do
 echo "Looping...";
 sleep 30;
 done
 
 # [optional] 2. 复制程序至 /usr/bin
 $ sudo cp test_service.sh /usr/bin/test_service.sh
 $ sudo chmod +x /usr/bin/test_service.sh
 
 # [required] 3. 创建 Unit File
 #
 [Unit]
 Description=Example systemd service.
 
 [Service]
 Type=simple
 ExecStart=/bin/bash /usr/bin/test_service.sh
 
 [Install]
 WantedBy=multi-user.target
 
 # [required] 4. 复制 Unit File 至 /etc/systemd/system
 $ sudo cp myservice.service /etc/systemd/system/myservice.service
 $ sudo chmod 644 /etc/systemd/system/myservice.service
 
 |