Linux 系統設置sh文件開機自啟動


   工作中有一個linux下的服務需要啟動,但是機器總是斷電,導致需要反復啟動,找了一下開機自啟動的方法,解決了這個問題。Linux設置開機自啟動非常簡單,只要找到rc.local文件,將你需要自啟動的文件加進去即可。我的linux服務器的rc.local文件在/etc文件夾下。rc.local文件沒有修改之前是這樣滴:

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

 

在文件下方直接添加你需要自啟動文件的路徑,然后直接寫上啟動命令,修改后的文件如下:

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

cd /root/apache-tomcat-6.0.37/bin
./startup.sh

 

 

是不是非常簡單呢


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM