CentOS-centOS下设置Rabbitmq服务开机自动启动的方法?

意见反馈 意见反馈 主题:991 回复:2082

CentOS-centOS下设置Rabbitmq服务开机自动启动的方法?

甜柠檬 发布于 2017-07-31 字数 377 浏览 1235 回复 1

在网上找到了一些linux下设置服务开启启动的方法,试了试都达不到效果。
like:http://blog.renhao.org/2010/05/centos...
我不知道chkconfig —add postfix怎么使用,才能把/usr/local/sbin/rabbitmq-server服务加进去!

又找了个修改/etc/rc.local文件的方法,设置后重启还是不行!
我怀疑是因为开启rabbitmq需要root权限的原因吧?

请问大家还有其他方法么?

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

支持 Markdown 语法,需要帮助?

评论(1

偏爱自由 2017-10-06 1 楼

我是这么做的,首先写一个控制脚本
vim /etc/init.d/myapp
chmod 755 /etc/init.d/myapp

然后
chkconfig --add myapp
chkconfig myapp on

最后查看是否已经在列表里
chkconfig --list

如cron服务的控制脚本

! /bin/bash

crond Start/Stop the cron clock daemon.

chkconfig: 2345 90 60

description: cron is a standard UNIX program that runs user-specified

programs at periodic scheduled times. vixie cron adds a

number of features to the basic UNIX cron, including better

security and more powerful configuration options.

processname: crond

config: /etc/crontab

pidfile: /var/run/crond.pid

Source function library.

. /etc/init.d/functions
. /etc/sysconfig/crond
t=${CRON_VALIDATE_MAILRCPTS:-UNSET}
[ "$t" != "UNSET" ] && export CRON_VALIDATE_MAILRCPTS="$t"

See how we were called.

prog="crond"

start() {
echo -n $"Starting $prog: "
if [ -e /var/lock/subsys/crond ]; then
if [ -e /var/run/crond.pid ] && [ -e /proc/cat /var/run/crond.pid ]; then
echo -n $"cannot start crond: crond is already running.";
failure $"cannot start crond: crond already running.";
echo
return 1
fi
fi
daemon crond $CRONDARGS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/crond;
return $RETVAL
}

stop() {
echo -n $"Stopping $prog: "
if [ ! -e /var/lock/subsys/crond ]; then
echo -n $"cannot stop crond: crond is not running."
failure $"cannot stop crond: crond is not running."
echo
return 1;
fi
killproc crond
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/crond;
return $RETVAL
}

rhstatus() {
status crond
}
restart() {
stop
start
}

reload() {
echo -n $"Reloading cron daemon configuration: "
killproc crond -HUP
RETVAL=$?
echo
return $RETVAL
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload)
reload
;;
status)
rhstatus
;;
condrestart)
[ -f /var/lock/subsys/crond ] && restart || :
;;
*)
echo $"Usage: $0 {start|stop|status|reload|restart|condrestart}"
exit 1
esac