linux 設(shè)置go程序開機(jī)啟動(dòng)

采用chkconfig 方式設(shè)置程序開機(jī)啟動(dòng)
1,編寫啟動(dòng)腳本,路徑? cd /etc/init.d/名稱


#!/bin/bash

# chkconfig: - 85 15

# description: rc.local is a local customized. It is used to serve

# @Author:dfsxh

# @Date: 2019-06-29 17:44:45

# @Last Modified by: dfsxh

# @Last Modified time: 2019-06-29 17:44:45

start(){?

? ? ? ? cd /www/wwwroot/qncms/

????????nohup ./qn_web_api &

????????echo "服務(wù)已啟動(dòng)..."

????????sleep 1

}?

stop(){?

? ? ? ? killall qn_web_api

????????echo "服務(wù)已停止..."

????????sleep 1

}

case "$1" in?

????start) start;;

????stop) stop;;

????restart) start;;

????reload) start;;

????status) start;;

? ? *)

? ? ? ? echo "$0 {start|stop|restart|reload|status}"

? ? ? ? exit 4

? ? ? ? ;;

esac?


也可以復(fù)制程序自帶腳本 aegis 在start() 方法中直接添加啟動(dòng)指令即可

2,使用chmod 777 名稱? 腳本文件和授權(quán)文件有執(zhí)行權(quán)限

3,服務(wù)添加到服務(wù)列表 chkconfig --add 名稱

4,查詢服務(wù)列表確認(rèn)添加成功 chkconfig --list

5,開啟服務(wù) chkconfig 名稱 on

6,啟動(dòng)服務(wù) service 名稱 start

7,重啟服務(wù)器程序即可開機(jī)啟動(dòng)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容