码迷,mamicode.com
首页 > 其他好文 > 详细

【CentOS】自定义服务添加

时间:2018-09-16 18:01:54      阅读:376      评论:0      收藏:0      [点我收藏+]

标签:add   gre   权限   short   mbed   pts   service   config   required   

1、创建服务需要执行的脚本

cd /sb/scripts

vi td-agent-testlog
#!/bin/bash
#
# /etc/rc.d/init.d/td-agent-DC01
#
# chkconfig: - 80 20
# description: td-agent-DC01
# processname: td-agent-DC01
# pidfile: /var/run/td-agent/td-agent-DC01.pid
#
### BEGIN INIT INFO
# Provides:          td-agent-DC01
# Default-Stop:      0 1 6
# Required-Start:    $local_fs
# Required-Stop:     $local_fs
# Short-Description: td-agents init script
# Description:       td-agent is a data collector
### END INIT INFO

/etc/init.d/td-agent-main td-agent-24240 root $*

2、修改脚本执行权限

chmod 755 td-agent-testlog

3、创建文件链接

cd /etc/init.d
ln -s /sb/scripts/swlog/td-agent-testlog sb_td-agent-testlog

4、添加服务

chkconfig --add sb_td-agent-testlog

chkconfig sb_td-agent-testlog on

chkconfig --list | grep sb
sb_td-agent-testlog 0:off   1:off   2:on    3:on    4:on    5:on    6:off

5、开启服务

service sb_td-agent-testlog start
Starting td-agent: td-agent-testlog:                   [  OK  ]

ps -ef | grep td-agent
root     22863     1  0 14:04 ?        00:00:00 /opt/td-agent/embedded/bin/ruby /usr/sbin/td-agent -v --group root --log /var/log/td-agent/td-agent-testlog.log --config /etc/td-agent/td-agent-24240.conf --daemon /var/run/td-agent/td-agent-24240.pid
root     22866 22863  0 14:04 ?        00:00:00 /opt/td-agent/embedded/bin/ruby /usr/sbin/td-agent -v --group root --log /var/log/td-agent/td-agent-testlog.log --config /etc/td-agent/td-agent-24240.conf --daemon /var/run/td-agent/td-agent-24240.pid

 

【CentOS】自定义服务添加

标签:add   gre   权限   short   mbed   pts   service   config   required   

原文地址:https://www.cnblogs.com/lixiaobin/p/centoschkconfigadd.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!