Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep redis server running

Tags:

redis

I am using redis for session support in nodejs app. I have installed redis server and it works when I run redis-server, but when I close terminal redis stops and does not work. How do I keep redis server running after closing the terminal?

like image 706
Yalamber Avatar asked Feb 11 '13 16:02

Yalamber


People also ask

How do I run Redis locally?

To start Redis client, open the terminal and type the command redis-cli. This will connect to your local server and now you can run any command. In the above example, we connect to Redis server running on the local machine and execute a command PING, that checks whether the server is running or not.

How do I run Redis in daemon?

To start: the redis daemon with sudo systemctl start redis@instanceName where you substitue "instanceName". Also sudo systemctl enable redis@instanceName for auto-starting on boot.


2 Answers

And, if you'd like a quick option, run: redis-server --daemonize yes.

like image 121
lakesare Avatar answered Oct 13 '22 06:10

lakesare


The easiest way to launch Redis as a daemon is to edit the configuration file and change the following line:

# By default Redis does not run as a daemon. Use 'yes' if you need it. # Note that Redis will write a pid file in /var/run/redis.pid when daemonized. daemonize yes 

Be sure to provide the configuration file on the redis-server command line when you launch it.

An example of configuration file is provided in the Redis distribution.

like image 44
Didier Spezia Avatar answered Oct 13 '22 04:10

Didier Spezia