12

I have installed redis server on my Ubuntu based server, so I can start/stop/restart redis server. The redis_server.sh is already in the /etc/init.d.

Now I want to make redis start on boot. I learned from a website that by working with the update_rc.d command, I can add / remove the service on boot.

I tried the update-rc.d to add startup on boot, which doesn't work:

root@ip-172-31-4-108:/etc/init.d# update-rc.d redis-server defaults
//System start/stop links for /etc/init.d/redis-server already exist.

In addition, there are some services I don't want to startup on boot, so I tried:

root@ip-172-31-4-108:/etc/init.d# update-rc.d reids_6379 remove
 Removing any system startup links for /etc/init.d/reids_6379 ...

But when rebooting next time, I still see that service running on boot.

16

For removing services you must use the -f parameter:

sudo update-rc.d -f <service> remove

For configuring startup on boot, try:

sudo update-rc.d <service> enable

See if the following symlink is created:

/etc/rc.2d/S20<service>

or something similar.

6
  • It doesn't works for me but it does. By some reason enable is not creating the file at /etc/rc..
    – deFreitas
    Jul 14 '18 at 18:26
  • Do you receive an error? Try "sudo update-rc.d <service> defaults"
    – erny
    Jul 16 '18 at 18:11
  • No, I ran then it does nothing and give no output
    – deFreitas
    Jul 16 '18 at 19:54
  • Debian 9 x64 logged as root
    – deFreitas
    Jul 16 '18 at 19:54
  • It's some specific issue with Debian in that version, I already tried it before and it works in Ubuntu at least
    – deFreitas
    Jul 16 '18 at 20:00
3

In ubuntu version 18.04 TLS, I found that update-rc.d does not work fine if there is no specific comment block in the start script that looks like this:

### BEGIN INIT INFO
# Provides: myprogram
# Required-Start: $ local_fs $ remote_fs $ syslog $ network $ time
# Required-Stop: $ local_fs $ remote_fs $ syslog $ network
# Default-start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: myprogram some description
### END INIT INFO
1
  • On Raspbian Buster (v10) #! /bin/sh must appear right before the BEGIN INIT INFO block.
    – R01k
    Nov 3 '19 at 2:30
0

Hate to admit that none of this worked on Raspberry Pi (Debian 10). If I want to stick with old school /etc/init.d/my_script location I needed to do the following.

# runlevel
N 5
# cd /etc/rc5.d
# ln -s ../init.d/my_script S40my_script


(probably should be done for other runlevels as well)
# ls /etc/rc5.d/ | grep my_script
S40my_script

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.