我想添加redis到启动我的CentOS虚拟机,但chkconfig似乎并没有添加它。 我遵循同样的过程为其他一些初始化脚本,他们被添加就好了。任何帮助告诉我我做错了什么会很好。 我已经看过man pages和google搜索过,但是每件事都说要添加我已经拥有的标题值。我为hornetq init脚本和smpp模拟器脚本编写了相同的case语句,并简单地改变了do_start和do_stop函数的内容来完成他们各自的工作。chkconfig不添加redis初始化脚本
我运行下面的命令来添加初始化脚本:
chkconfig --add /etc/init.d/redis
然后我检查清单,:
chkconfig --list
导致:
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'.
hornetq 0:off 1:off 2:off 3:on 4:on 5:on 6:off
netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
smppsim 0:off 1:off 2:off 3:on 4:on 5:on 6:off
脚本我写过这样的文字:
#!/bin/sh
#
# startup script for running redis as a service.
#
# chkconfig: 350 95 15
# description: redis startup script
do_start(){
systemctl start redis.service
}
do_stop(){
systemctl stop redis.service
}
do_status(){
systemctl status redis.service
}
case "$1" in
'start')
do_start
do_status
;;
'stop')
do_stop
do_status
;;
'status')
do_status
;;
'restart')
do_stop
do_start
;;
*)
echo "usage: $0 start|stop|status|restart"
esac
*****编辑******
只是一个供参考运行 “服务的Redis启动” 工作得很好
所以这并没有完全回答这个问题,但它确实指向了我相信的正确方向。我想我应该使用systemctl enable redis.service – peekay
是的,这会将服务设置为在systemd启动时启动。我不清楚(尽管也许应该是),那是这里的最终目标。抱歉。 –