采用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)