Centos7设置开机启动

设置服务开机启动
systemctl enable 服务名
比如docker: systemctl enable docker
设置脚本开机启动

比如说我们把服务部署到tomcat中,我们需要设置tomcat开机启动。

①首先需要准备脚本,比如脚本名称为tomcat_8080,编写tomcat启动脚本可参考tomcat启动脚本

② 将脚本移动到 /etc/init.d目录下面

mv tomcat_8080 /etc/init.d

③ 赋予脚本执行权限

chmod +x tomcat_8080

④添加脚本为开机启动,执行以下两个命令

chkconfig --add tomcat_8080
chkconfig tomcat_8080 on

删除命令为:chkconfig --del tomcat_8080

⑤查看是否设置成功

chkconfig --list

显示结果为:

tomcat_8080     0:off   1:off   2:on    3:on    4:on    5:on    6:off

这里的显示和脚本里的:#chkconfig:2345 80 05 有关
级别2345为on,表示设置成功了。

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