Linux添加系统服务小程序

如何增加一个服务:
1.服务脚本必须存放在/etc/ini.d/目录下;
2.chkconfig --add servicename
    在chkconfig工具服务列表中增加此服务,此时服务会被在/etc/rc.d/rcN.d中赋予K/S入口了;
3.chkconfig --level 35 mysqld on
    修改服务的默认启动等级。
4 启动停止
service servicename start
service servicename stop

 Linux 开机启动项目

http://www.ruanyifeng.com/blog/2013/08/linux_boot_process.html

1 在/usr/bin 目录下添加hello.sh 文件 echo "hello"

2 添加到/etc/rc.d/init.d/文件夹之下 文件名sayhello

### BEGIN INIT INFO
# Provides:          scriptname
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     3 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO

#!/bin/bash

/usr/bin/hello.sh
 

3 chmod 777 /usr/bin/hello.sh

   chmod 777 /etc/rc.d/init.d/sayhello

4

chkconfig --add sayhello
chkconfig --level 35 sayhello on

5 在rc5.d做一个相应的软连接 ln -s /etc/rc.d/init.d/sayhello /etc/rc5.d/Ssayhello@

 ============================================================ 服务等级相关 1 修改服务文件 /etc/init.d/目录下: 关建行

 

# Default-Start:     2 3 4 5

 

testser 文件内容:

### BEGIN INIT INFO
# Provides:          scriptname
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO

#!/bin/bash

/usr/bin/hello.sh

 

 

 

2 做如下相关配置



 

 

 

 

 

 

 

 

 

 

 

猜你喜欢

转载自cici-new-1987.iteye.com/blog/1965461