注意:本篇文章不會教你如何從 0 開始設定 systemd ,因此在閱讀以前請先自行了解 systemd 。

  1. xxxx.service 必須放在 /etc/systemd/system 下
  2. xxxx.service 內必有 ExecStart 此參數
[Service]
ExecStart=/etc/init.d/xxx
  1. ExecStart 所指向的執行檔必須在 /etc/init.d 下 
  2. /etc/init.d 執行檔內的開頭必須要有以下內容
#!/bin/sh
### BEGIN INIT INFO
# Default-Start: 2 3 4 5
# Default-Stop:
### END INIT INF

( 第一列的 #!/bin/sh 可視你的執行檔屬性而有所不同 )

  1. 一切設定好後 reload + 啟用 service
systemctl daemon-reload
systemctl enable xxxx
  1. 試著重開機後檢查狀態吧
reboot
systemctl status xxxx