centos7 开机启动某些程序的方法

针对svn,nginx每次重启后均要手工启动,好麻烦,所以考虑将其做成开机启动,做成服务好麻烦,考虑像windows 一样,放在某个启动项中完成。

打开启动文件后,发现里面文件内容如下:

#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

意思很简单,需要将此文件权限改为可执行的,这也是为何开机后此文件不能执行的原因

 

操作步骤:

 

1、添加可执行权限:

# chmod +x /etc/rc.d/rc.local

 

2、打开文件rc.local:

# vim /etc/rc.d/rc.local

 

3、在文件rc.local末添加开机应启动的脚本:

svnserve -d -r /var/svn
/usr/nginx/sbin/nginx

 

4、重启机器,验证svn和nginx已经启动成功

# reboot

posted @ 2016-06-12 10:07  绿色的麦田  阅读(4387)  评论(0编辑  收藏  举报