我想添加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啓動時啓動。我不清楚(儘管也許應該是),那是這裏的最終目標。抱歉。 –