I am trying to add redis to the start up of my CentOS vm, but chkconfig does not seem to be adding it. I followed the same process for a couple other init scripts and they were added just fine. Any help to show me what I am doing wrong would be great. I have looked at the man pages and google searched but every thing says to add the header values that I already have. I wrote the same case statements for the hornetq init script and the smpp simulator scripts and simply changed the content of the do_start and do_stop functions to do their respective jobs.
I am running the following command to add the init script:
chkconfig --add /etc/init.d/redis
Then I check the list with:
chkconfig --list
which results in:
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
The script I have written looks like this:
#!/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
*****EDIT******
just an FYI running "service redis start" works just fine
The command is chkconfig --add [name]
not chkconfig --add [path]
so you want chkconfig --add redis
.
That being said on a systemd system you shouldn't even bother with a init.d service script since you don't need it.
The "legacy" service
command was updated to handle starting systemd services normally so you possibly/probably aren't even using your script (and if you are since your script just forwards to systemctl
you don't need it since, as I said, the service
command already does that for you).
To emulate the chkconfig
functionality of starting a service on boot you want to use systemctl enable <service>
.