Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

want to run redis-server in background nonstop

I have downloaded redis-2.6.16.tar.gz file and i installed sucessfully. After installed i run src/redis-server it worked fine.

But i don't want manually run src/redis-server everytime, rather i want redis-server running as background process continuously.

So far after installed i did following tasks:

1. vim redis.conf and i changed to

# 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

But same result i found. What mistake i did?

After redis run in background. I will run juggernaut also as background process with following command.

nohup node server.js

But i am not able to make redis run in background. Please provide some solution.

like image 926
siv rj Avatar asked Jun 14 '14 15:06

siv rj


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 stop Redis from running in the background?

Stopping the Redis Server If you started the Redis server using the redis-server command, you could stop the Redis server by pressing CTRL + C.

How do I know if Redis is running?

you can do it by this way. $redis = new Redis(); $redis->connect('127.0. 0.1', 6379); echo $redis->ping(); and then check if it print +PONG , which show redis-server is running.


4 Answers

Since Redis 2.6 it is possible to pass Redis configuration parameters using the command line directly. This is very useful for testing purposes.

redis-server --daemonize yes 

Check if the process started or not:

ps aux | grep redis-server 
like image 135
Sagar Ranglani Avatar answered Oct 12 '22 17:10

Sagar Ranglani


I think the best way is to use Redis' config file:

# 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 

Set daemonize to yes in the config file. Say the file is ~/.redis/redis.conf, then just run

$ redis-server ~/.redis/redis.conf 

And it just works.

like image 27
laike9m Avatar answered Oct 12 '22 16:10

laike9m


Or you can simply run it as src/redis-server redis.conf&

like image 29
Chhavi Gangwal Avatar answered Oct 12 '22 17:10

Chhavi Gangwal


For windows:

Step 1: Install redis as a service

redis-server --server-install 

Step 2: Run background

redis-server --server-start 
like image 21
Huy Do Quoc Avatar answered Oct 12 '22 15:10

Huy Do Quoc