linux設置自啓動,mongodb自啓動

linux建立自啓動腳本linux

一、進入目錄mongodb

cd /etc/init.d
複製代碼

二、建立腳本文件bash

touch start-mongodb.sh
複製代碼

三、編寫腳本app

#!/bin/sh
# chkconfig: 345 99 10
# description: Auto-starts mongodb
echo "start mongodb"
cd /bigdata/app/mongodb-4.0.2/bin		#cd 進入指定目錄
./mongod -f ../mongo.conf		#./mongod 執行目錄下的mongod.sh腳本
複製代碼

三、受權,掛載,查看ui

chmod +x /etc/init.d/start-mongodb.sh	#增長執行權限

ln -s  /etc/init.d/start-mongodb /etc/rc2.d/S16mongodb		#掛載,執行命令

chkconfig --add start-mongodb.sh		#把startTest添加到系統服務列表

chkconfig start-mongodb.sh on		#設定startTest的開關(on/off)

chkconfig --list start-mongodb.sh   #查看已經註冊的start-mongodb服務
複製代碼
相關文章
相關標籤/搜索