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

轉載: https://www.cnblogs.com/DylanZ/p/5864771.html

 

工作中有一個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

 

 

是不是非常簡單呢

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章