service to start on boot doesn't work with update-rc.d command
Solution 1
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
Solution 2
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.
Solution 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
Related videos on Youtube
user824624
Updated on September 18, 2022Comments
-
user824624 over 1 year
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.
-
deFreitas almost 6 yearsIt doesn't works for me but it does. By some reason enable is not creating the file at /etc/rc..
-
erny almost 6 yearsDo you receive an error? Try "sudo update-rc.d <service> defaults"
-
deFreitas almost 6 yearsNo, I ran then it does nothing and give no output
-
deFreitas almost 6 yearsDebian 9 x64 logged as root
-
deFreitas almost 6 yearsIt's some specific issue with Debian in that version, I already tried it before and it works in Ubuntu at least
-
Jeff Terrell Ph.D. over 5 yearsI'm on Ubuntu 18.04 and this didn't work. When I used the command given in the answer linked in the first comment (
systemctl enable jira
in my case), I got an error:update-rc.d: error: jira Default-Start contains no runlevels, aborting.
. (Maybe that's why the update-rc.d command is silently failing? I don't know.) I then copied the comment block at the start of another service in /etc/init.d/, modifying a few details, and then thesystemctl
command worked. -
R01k over 4 yearsOn Raspbian Buster (v10) #!
/bin/sh
must appear right before the BEGIN INIT INFO block.