源码方式安装mosquitto之后,如何编写init.d脚本

azhilee 2018-10-03 01:47:40
源码方式安装mosquitto之后,想通过 service mosquitto start | stop | status | restart 管理,
可是好像mosquitto本身没有提供stop的方法,应该怎么来编写
...全文
223 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
azhilee 2020-11-30
  • 打赏
  • 举报
回复
有这个角本,就可以通过 service mosquitto enable 的方式让mosquitto自启动 或者可以通过 service mosquitto reset 让mosquitto重启 等等
蓝胖子plus 2019-04-22
  • 打赏
  • 举报
回复
想问一下您这个代码是实现了什么功能呢
azhilee 2018-10-03
  • 打赏
  • 举报
回复
成功了

kill -QUIT `cat $pidfile`
azhilee 2018-10-03
  • 打赏
  • 举报
回复
kill $pidfile 没用
azhilee 2018-10-03
  • 打赏
  • 举报
回复
写了一个 加到chkconfig里了 可以自启动 但是不会停

#!/bin/sh

# chkconfig: 35 85 15

# description: Mosquitto

pidfile="/var/run/mosquitto.pid"
config="/etc/mosquitto/mosquitto.conf"

. /etc/rc.d/init.d/functions

export HOME=/root

start() {
echo "starting mosquitto..."
/usr/local/sbin/mosquitto -c $config -d
return
}

stop() {
echo "stoping mosquitto..."
kill 2754
return
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
esac

kill好像不起作用
aabbabababaa 2018-10-03
  • 打赏
  • 举报
回复
参照着写脚本,放在systemd里试下了

19,610

社区成员

发帖
与我相关
我的任务
社区描述
系统使用、管理、维护问题。可以是Ubuntu, Fedora, Unix等等
社区管理员
  • 系统维护与使用区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧