1、Linux開機啓動有多種方法,好比我設置mysql開機啓動爲:chkconfig --level 35 mysqld onmysql
2、下面說說經過rc.local文件進行開機啓動:redis
一、首先建立一個啓動腳本,這裏以redis啓動爲例sql
建立 redis-startup.sh 腳本vim
#!/bin/sh echo "-----------------------------------------------------------------------------" >> /root/start-up/redis.log echo -e "`date +%Y/%D/%H:%M` redis start up..." >> /root/start-up/redis.log /usr/local/redis-5.0.5/src/redis-server /usr/local/redis-5.0.5/redis.conf >> /root/start-up/redis.log 2>&1 sleep 3 netstat -tunpl | grep 6358 >> /root/start-up/redis.log 2>&1 echo -e "`date +%Y/%D/%H:%M` redis start end." >> /root/start-up/redis.log echo -n " " >> /root/start-up/redis.log
並給 redis-startup.sh 設置執行權限:spa
chmod +x redis-startup.sh
二、在 /etc/rc.local 末尾增長 redis-startup.sh 腳本code
# vim /etc/rc.local # 追加到末尾便可
# /root/start-up/redis-startup.sh
並給 rc.local 設置執行權限server
chmod +x /etc/rc.local
三、從新啓動,驗證結果。blog