1. 將寫好的 script 放在 /usr/local/etc/rc.d/ 之,檔案名稱一定要有 .sh 為結尾(ex. your_script.sh)
2. 變更權限 sudo chomd 755 your_script.sh
3. script 內容必須包含 start 和 stop 等參數,範例如下
#!/bin/sh # # Put this file in /usr/local/etc/rc.d/your_script.sh case "$1" in stop) echo "[Stop]" # do something here" ;; start) echo "[Start]" sudo "/volume1/matt/your_script.sh" ;; restart) echo "[Restart]" $0 stop sleep 1 $0 start ;; status) ps | grep laravel_queue_listen | grep -v grep ;; *) echo "usage: $0 { start | stop | restart | status}" >&2 exit 1 ;; esac之後你可以透過手動 ./your_script.sh start|stop|restart 來操作。
在系統開機時也會自動執行 ./your_script.sh start
可參考官方文件 [Run Scripts When the System Boots]
https://originhelp.synology.com/developer-guide/integrate_dsm/run_with_system_boot.html