32

I am using Ubuntu to develop my website. Recently, I started to use redis.

When I started my computer, redis-server will start by its own.

What method can I stop my redis-server starting by itself?

LiJung
  • 7,649
  • 6
  • 27
  • 30

2 Answers2

38

It seems that the redis-server package uses rc.d scripts, and the preferred way to deal with them in Ubuntu is using update-rc.d:

sudo update-rc.d redis-server disable

Should do the trick. You can also disable it in a certain runlevel only:

sudo update-rc.d redis-server disable 2 
Linus Thiel
  • 38,647
  • 9
  • 109
  • 104
  • 2
    did **not work** for me, getting `update-rc.d: /etc/init.d/redis-server: file does not exist` warning. Using **Ubuntu 14.04 & Redis 3.0.7** which is the latest version available. – talha06 Feb 24 '16 at 07:59
  • 1
    @talha06 did you install the redis-server deb package using apt, or did you build it from sources or another installation method? – Linus Thiel Feb 24 '16 at 10:11
  • I built it from the sources since it is the way Redis guides: http://redis.io/download – talha06 Feb 24 '16 at 10:57
  • 6
    That explains it, this advice is for the Ubuntu package of redis. I don't know how vanilla redis handles init scripts, but [this part of the README](https://github.com/antirez/redis#installing-redis) says it will be called "redis_", so `sudo update-rc.d redis_6379 disable` should work if it's on the default port. – Linus Thiel Feb 24 '16 at 12:36
  • @LinusGustavLarssonThiel that indeed works! Thanks, maybe it would make sense to edit the original answer? – Capaj Nov 22 '16 at 17:15
  • This answer is outdated, see the other answer https://stackoverflow.com/questions/11857198/how-to-stop-redis-server-autostart/51140929#51140929 – DLight Oct 14 '21 at 12:11
32

For those looking for a more up-to-date solution. If your system is using systemd (Ubuntu 15.04 and up) the way to not launch it at start-up is:

sudo systemctl disable redis-server

systemctl admits "basically" these actions (check the following links for the complete list)

  • disable. Don't launch at boot.
  • enable. Launch at boot.
  • start. Launch it now.
  • stop. Stop it now.
  • status. To check if is running

As written in this answer:

For more details, see enabling-and-disabling-services and for the very long answer see this post

For more details, see this post on Digital Ocean and the man page for systemctl.

Francisco Puga
  • 23,869
  • 5
  • 48
  • 64